Android Question Error: Object should first be initailized

lock255

Well-Known Member
Licensed User
Longtime User
Hi all, in my last app I have a problem, if the compiled in Release (obfuscated) mode, it gives me no error navigazie but then when I go to open a new activity, I have this error:
B4X:
java.lang.runtimeexception object should first be initialized (listview)

As if I compile in Release mode, I haven't this error.
According to you, this failure may be due to what?
 

lock255

Well-Known Member
Licensed User
Longtime User
In the designer I have add a listview, while I put this in the code:
B4X:
Sub Globals
    Dim listHelp As ListView
    Dim ForumSupport As PhoneIntents
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("help")
    listHelp.SetLayout(0%x,0%y,100%x,100%y)
   
    'listHelp.AddSingleLine("Support")
    listHelp.AddTwoLinesAndBitmap(Main.L_Support, Main.L_Support_community,LoadBitmap(File.DirAssets,"community.png")) 
    listHelp.AddTwoLinesAndBitmap(Main.L_Donation, Main.L_Donation_info,LoadBitmap(File.DirAssets,"heart.png")) 
    listHelp.AddTwoLinesAndBitmap(Main.L_Contact_us, Main.L_Contact_send_email,LoadBitmap(File.DirAssets,"email.png"))
    listHelp.AddTwoLinesAndBitmap(Main.L_Info, Main.L_Info_app,LoadBitmap(File.DirAssets,"info.png"))
End Sub


Sub listHelp_ItemClick (Position As Int, Value As Object)
    If Value=Main.L_Support Then
    StartActivity(form1)
    Else If Value=Main.L_Donation Then
    StartActivity(form2)
    Else If Value=Main.L_Contact_us Then
    StartActivity(sendemail)
    Else If Value=Main.L_Info Then
    StartActivity(versioninfo)
    End If
End Sub
 
Upvote 0

lock255

Well-Known Member
Licensed User
Longtime User
I was not given any error line, only the following message:
B4X:
java.lang.runtimeexception object should first be initialized (listview)
 
Upvote 0

lock255

Well-Known Member
Licensed User
Longtime User
Return this log:
B4X:
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:46)
    at anywheresoftware.b4a.objects.ViewWrapper.SetLayout(ViewWrapper.java:255)
    at halloweensounds.xperiasoftware.com.sendemail._activity_create(sendemail.java:309)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at halloweensounds.xperiasoftware.com.sendemail.afterFirstLayout(sendemail.java:98)
    at halloweensounds.xperiasoftware.com.sendemail.access$100(sendemail.java:16)
    at halloweensounds.xperiasoftware.com.sendemail$WaitForLayout.run(sendemail.java:76)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:213)
    at android.app.ActivityThread.main(ActivityThread.java:4787)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (Label).

I also underlined the variables:
B4X:
Dim btnClear As Button
    Dim btnSend As Button
    Dim lbMessage As Label
    Dim lbSubject As Label
    Dim txtMessage As EditText
    Dim txtSubject As EditText

and as a suggestion on them it says: Variable 'btnClear' was not initialized. (waming#11)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…