Android Question B4XView - Error compiling a code module to library

Discussion in 'Android Questions' started by LucaMs, May 8, 2018.

  1. LucaMs

    LucaMs Expert Licensed User

    I have a code module (b4a) in which all the routines require variables of type B4XView as parameters.

    This code module works well in b4a and b4j projects. I compiled the module to a b4a library.

    Then I ran the same project (b4a) which used the code module, replacing the module with the library and I get this error at compilation time:

    src\b4a\example\ error: incompatible types: Button cannot be converted to B4XViewWrapper
    parent.mostCurrent._xviewpos._viewsetrelright(mostCurrent.activityBA,(anywheresoftware.b4a.objects.B4XViewWrapper)(parent.mostCurrent._btntomove.getObject()),(anywheresoftware.b4a.objects.B4XViewWrapper)(parent.mostCurrent._button2.getObject()),(int) (0));

    P.S. I watched xCustomListView. In it, Add requires a B4XView as parameter (name pnl) and it works :eek:

    P.P.S. Works it? I'm not sure, always used as class.
    Last edited: May 8, 2018
  2. LucaMs

    LucaMs Expert Licensed User

    I really don't understand.

    xCustomListview has a method (Add) that requires a B4XView object (Pnl) as parameter. It works as class and even compiled as library.

    My module (post #1) does not work if compiled.

    I "worked" on the ClockView example:

    It works even if compiled.
    I added just a single routine to the original source code:
    Public Sub MoveView(V As B4XView)
    If V.Left = 0 Then
            V.Left = V.Parent.Width - V.Width
            v.Left = 
    End If
    End Sub
    Then the modified ClockView works if used as class, added to a project as class; but it's impossible to use the compiled version (same error message - see post #1).

    So this works (xCustomListView):
    Public Sub Add(Pnl As B4XView, Value As Object)
    this not ("my" ClockView):
    Public Sub MoveView(V As B4XView)

    Attached Files:

  3. LucaMs

    LucaMs Expert Licensed User

    "Big step forward": I copied that routine (MoveView) into the xCustomListView source. Here it works! :eek:
  4. klaus

    klaus Expert Licensed User

    Sorry, I don't understand.
    I tried your project and it works as expected!?
    So where is the problem?
    I loaded you project from post#2.
    I compiled it as is, and it works.
    I compiled it to a library.
    Refreshed the Library Manager Tab and checked xClockView.
    Then, I removed the ClockView module and the program works as expected !
    LucaMs likes this.
  5. LucaMs

    LucaMs Expert Licensed User

    Instead you understood correctly, Klaus.

    Can you try the project I'm attaching? It is a test with the view compiled.

    I still get this error:

    B4A line: 45
    javac 1.8.0_66
    src\b4a\example\ error: incompatible types: Button cannot be converted to B4XViewWrapper


    [Note that the "main problem" started with a code module compiled as library, the rest was tests]

    Attached Files:

  6. LucaMs

    LucaMs Expert Licensed User

    I was in a hurry; it would not be a good test, without the library.

    Attached Files:

  7. klaus

    klaus Expert Licensed User

    You must check the XUI library in your project!
    LucaMs likes this.
  8. LucaMs

    LucaMs Expert Licensed User

  9. LucaMs

    LucaMs Expert Licensed User

    Kill me, please :D:(
  10. LucaMs

    LucaMs Expert Licensed User

    But... Now I don't have time to do tests, but usually you don't need to add a reference to a library altready referenced in a library you want to use (if I'm not wrong; now I'm quite busy and confused!).
  11. LucaMs

    LucaMs Expert Licensed User

    Maybe I'm wrong but you can create code modules and classes (custom view) for all the three platforms (B4A, B4J, B4I) but then you have to compile three different libraries, one for each platform.

    P.S. If there are XUI, jXUI and iXUI this is sure.
  12. klaus

    klaus Expert Licensed User

    There are three different XUI libraries, each product has its own.
    When you develop an XUI class, the code is the same for all three products, the same file.
    But, if you want to compile it to a library, you must compile one library for each product!
    I suppose that with your library you still need to declare the XUI library in the main code because you transmit an object which needs to be transformed into a B4XView.
    LucaMs and Erel like this.
  13. LucaMs

    LucaMs Expert Licensed User

    I was not on this Earth, yestardey :(:D

    The "nice" thing is that I wanted to post some very simple routines in Snippets or suggest Erel to implement these routines directly in the Core.

    Then I preferred to use a code module and after that I wanted to compile it.

    I must say that in this case it is perhaps not very useful to use XUI.

    As soon as I'm better I'll evaluate where and what to publish.

    Thank you
  14. LucaMs

    LucaMs Expert Licensed User

    Right now I'm thinking to develop to a very nice app, which will not be much loved by "someone":

    a list of "Wishes" to be clicked only by b4x members, of course, and a statistic with the most clicked.

    Here, this is one of those posts that do not make me very well liked.


    So, why I post this? Because I am stupid, of course :D
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice