Android Question [solved] crash on LoadLayout when installing over older version

Dave O

Well-Known Member
Licensed User
Longtime User
Hi all,

Unexplained "LoadLayout" crash only when I try to install a new test version of my app over top of an older version. I've never seen this before, despite a long history of version updates. Crashes in Release mode and Debug mode. Here's the Debug log:

B4X:
Copying updated assets files (40)
*** Service (starter) Create ***
[...some normal log statements]
** Service (starter) Start **
** Activity (main) Create (first time) **
java.lang.NoSuchFieldException: No field mFastScroll in class Landroid/widget/AbsListView; (declaration of 'android.widget.AbsListView' appears in /system/framework/framework.jar!classes4.dex)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:38)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:338)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:133)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at name.obrien.dave.lister.main._createnavdrawer(main.java:1123)
    at name.obrien.dave.lister.main._activity_create(main.java:1045)
    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:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at name.obrien.dave.lister.main.afterFirstLayout(main.java:106)
    at name.obrien.dave.lister.main.access$000(main.java:18)
    at name.obrien.dave.lister.main$WaitForLayout.run(main.java:84)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8919)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at anywheresoftware.b4a.objects.ViewWrapper.buildNativeView(ViewWrapper.java:572)
    at anywheresoftware.b4a.objects.ButtonWrapper.build(ButtonWrapper.java:95)
    ... 26 more
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 4: TypedValue{t=0x2/d=0x1010099 a=1}, theme={InheritanceMap=[id=0x7f0c0005name.obrien.dave.lister:style/TextAppearance.Compat.Notification.Info.Media, id=0x7f0c0004name.obrien.dave.lister:style/TextAppearance.Compat.Notification.Info, id=0x1030200android:style/TextAppearance.Material.Notification.Info, id=0x10301feandroid:style/TextAppearance.Material.Notification, id=0x10301edandroid:style/TextAppearance.Material, id=0x103003eandroid:style/TextAppearance], Themes=[name.obrien.dave.lister:style/TextAppearance.Compat.Notification.Info.Media, forced, name.obrien.dave.lister:style/MyDarkTheme, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]}
    at android.content.res.TypedArray.getColor(TypedArray.java:529)
    at android.widget.TextView.readTextAppearance(TextView.java:4544)
    at android.widget.TextView.<init>(TextView.java:1442)
    at android.widget.Button.<init>(Button.java:174)
    at android.widget.Button.<init>(Button.java:149)
    at android.widget.Button.<init>(Button.java:125)
    at android.widget.Button.<init>(Button.java:104)
    ... 30 more
Error occurred on line: 470 (Main)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Button).
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at name.obrien.dave.lister.main._createnavdrawer(main.java:1123)
    at name.obrien.dave.lister.main._activity_create(main.java:1045)
    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:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at name.obrien.dave.lister.main.afterFirstLayout(main.java:106)
    at name.obrien.dave.lister.main.access$000(main.java:18)
    at name.obrien.dave.lister.main$WaitForLayout.run(main.java:84)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8919)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.RuntimeException: Object should first be initialized (Button).
Did you forget to call Activity.LoadLayout?
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.ViewWrapper.innerInitialize(ViewWrapper.java:73)
    at anywheresoftware.b4a.objects.ButtonWrapper.innerInitialize(ButtonWrapper.java:39)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:423)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:133)
    ... 20 more
** Activity (main) Resume **

(The mFastScroll exception only happens in Debug mode and has been there for years, doesn't seem to affect anything.)

The LoadLayout is done when I create the nav drawer using AHNavigationDrawer. This has worked fine in the past and I haven't changed it since.

If I uninstall the previous version, this new version installs and runs just fine. That should be a clue, but I'm not sure where to go from there.

Another clue: This started after I got a new laptop. I installed B4A 13.4 and all referenced libraries using the latest instructions. Initially forgot to set my private keystore, but fixed that later.

I've tried installing on several different devices and Android versions, building with SDK 34, 35, and 36, with targetSDK set to 34 and 35 - same result.

Because the crash mentions theme stuff, I replaced my custom theme with a minimal standard one and it still crashes, same error. Has been a real head-scratcher so far.

Any ideas? Thanks!
 
Last edited:

Dave O

Well-Known Member
Licensed User
Longtime User
Could this have anything to do with the signing key for the app? When I moved to a new laptop, I initially forgot to set this in B4A, until I got errors. Then I set up the key using the same keystore as before (migrated from the old laptop).
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
I removed the last custom library (UltimateListView) from my stripped-down app and no joy - still the same crash when updating from a previous version.

I'm running out of ideas. I can't update my app and I don't know why.

I'll try reinstalling B4A and Java and the SDK from scratch in case I missed something.

Argh.
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
Solved, after weeks of trying pretty much everything. I had 3 AI LLMs giving me suggestions (and confidently telling me they had found the problem each time) and finally I stumbled on something that worked.

The short version is that some part of my complex UI layout was not inflating properly, which apparently only became a bug under the latest SDK versions (35, 36, maybe even 34) which might have gotten stricter about this.

ChatGPT 5 suggested that I switch to an AppCompat theme, and the error disappeared. I'm now using a minimal theme that simply opts out of the edge-to-edge stuff in 35+. (I will deal with that later, when we come up with better solutions for it.)

I don't yet know if there are any real downsides to using an AppCompact theme (as opposed to Material), but so far everything is looking and working properly. No need to change any of the views and libraries I've been using for years.

Maybe there's a way to solve this with a Material theme, but I'm going with what works for now.

Thanks to everyone who offered their suggestions!
 
Upvote 0
Top