Android Question B4XPages & B4XDrawer -> App Crashes when Loading page with Drawer

Keith Flanagan

Member
Licensed User
Hi All

I am having an issue where my test app is crashing when moving to the second page of my App, It seems to relate to the left Pane drawer but I cant see what I am doing wrong.

Error log below, Also attached a sample project for reference.

One other question, How do I set the size for a Gif in the GifView, I want to center it i nthe gif, currently its quite large and the top of the gif animation is cut off.
B4XGifView1.SetGif(File.DirAssets, "800.gif")

Thanks

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 15 (B4XPages)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
    at b4a.example.issue.b4xnearbypage$ResumableSub_B4XPage_Appear.resume(b4xnearbypage.java:97)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
    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)
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 15 (B4XPages)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
    at b4a.example.issue.b4xnearbypage$ResumableSub_B4XPage_Appear.resume(b4xnearbypage.java:97)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
    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)
 

Attachments

  • Project.zip
    86.8 KB · Views: 74

Keith Flanagan

Member
Licensed User
So I have traced the crash to this line

B4X:
B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))

This is in the Appear function of the new page

B4X:
Private Sub B4XPage_Appear

I am just following Erel's example in (albeit without the lblHelloText and Update Image): https://www.b4x.com/android/forum/threads/b4x-b4xpages-b4xdrawer.120246/

B4X:
Private Sub B4XPage_Appear
    lblHello.Text = $"Hello ${B4XPages.MainPage.txtUser.Text}!"$
    UpdateImage
    #if B4A
    Sleep(0)
    B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
    Dim bd As BitmapDrawable
    bd.Initialize(HamburgerIcon)
    B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
    #End If
End Sub
 
Upvote 0

Keith Flanagan

Member
Licensed User
Ok so I found the Issue, I had set IncludeTitle to false in Main

B4X:
#IncludeTitle: False

Once I changed this too true the code stops crashing.

So this leaves me with 2 questions:

  1. How do I set the size for a Gif in the GifView, I want to center it in the gif, currently its quite large on screen, any way to shrink it and set a max size centered in the GifView?
  2. How can I remove the title for the B4XMain Page but add it for the second [Nearby] page?
 
Upvote 0

Keith Flanagan

Member
Licensed User
Hi All

Just wondering if anyone has an ideas about this:
  1. How do I set the size for a Gif in the GifView, I want to center it in the gif, currently its quite large on screen, any way to shrink it and set a max size centered in the GifView?
  2. How can I remove the title for the B4XMain Page but add it for the second [Nearby] page?
Thanks
 
Upvote 0

Mahares

Expert
Licensed User
How can I remove the title for the B4XMain Page but add it for the second [Nearby] page?
In B4XMainPage, you can add this line:
B4X:
B4XPages.SetTitle(Me,"")
To add a title for subsequent pages add to the corresponding page:
B4X:
B4XPages.SetTitle(Me,"Keith Flanagan")
By the way, members do not like it when you post the same exact question a day later to bump it up. They like you to wait until someone answers your original one. Not sure about your GIF question.
 
Upvote 0

angel_

Well-Known Member
Licensed User
I have the same problem:

B4X:
Error occurred on line: 15 (B4XPages)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:258)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:118)
    at com.xxx.b4xmainpage$ResumableSub_B4XPage_Appear.resume(b4xmainpage.java:1366)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7697)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

I have tried with #IncludeTitle: True but it doesn't work
 
Upvote 0

Keith Flanagan

Member
Licensed User
In B4XMainPage, you can add this line:
B4X:
B4XPages.SetTitle(Me,"")
To add a title for subsequent pages add to the corresponding page:
B4X:
B4XPages.SetTitle(Me,"Keith Flanagan")
By the way, members do not like it when you post the same exact question a day later to bump it up. They like you to wait until someone answers your original one. Not sure about your GIF question.

Thanks Mahares, Apologies since I answered my original question about the crash I thought my other questions may have got lost in the noise.
 
Upvote 0
Top