Android Question B4XView error (List)

fbritop

Active Member
Licensed User
Longtime User
Not sure where it comes to nor the title of this thread.

I have in B4XMainPage declared in Class_Globals:
B4X:
Dim pnlPager As B4XView

When B4XMain is created, I have a small delay, then I call a sub, which within it lines executes:

B4X:
            Log(pnlPager.IsInitialized)
            If pnlPager.IsInitialized Then '<--Line 1259
                pnlPager.RemoveViewFromParent
            End If

The wierd thing, is that the logs outputs:
B4X:
false
Error occurred on line: 1259 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (List).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1714)
    at android.os.Handler.handleCallback(Handler.java:888)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:213)
    at android.app.ActivityThread.main(ActivityThread.java:8178)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

So it argues that a B4XView, that returns false if it is initialized, but then within the if IsInitialized it crashes, even thow teh LOG() before showed it was false the condition. Moreover it argues that the object should first be initialized (List). When pnlPager is not a "List" but a B4XView.

There is no other part in the code that assigns a value to pnlPager
 

Situ LLC

Active Member
Licensed User
Me ha pasado , ponlo como public

Public pnlPager As B4XView

ME ha resuelto en varias opcaciones
SAlud
 
Upvote 0

Situ LLC

Active Member
Licensed User
Te soluciono ?
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
No, it did not help. Still I think is kind of a bug, because:

B4X:
            Dim propiedadesCount As Int=0
            Dim externalServicesCount As Int=0
            If Main.mapData.ContainsKey("propiedades") Then
                propiedadesCount=Main.mapData.Get("propiedades").As(List).Size
            End If
            If Main.mapData.ContainsKey("externalServices") Then
                externalServicesCount=Main.mapData.Get("externalServices").As(List).Size
            End If
            Dim totalSize As Int=propiedadesCount+externalServicesCount
            
            Log(totalSize)  '<--This output "0" in the logs
            Log(totalSize>1) '<--This output FALSE in the logs
            
            If totalSize>1 Then  '<--This is line 1261
                'TODO
            End if

And the logs tells me that totalSize is a List??

B4X:
0
false
Error occurred on line: 1261 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (List).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1714)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:236)
    at android.app.ActivityThread.main(ActivityThread.java:8056)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
 
Upvote 0
Top