I have an app that was working for quite some time now. I have a simple activity that retrieves JSON and stuffs it into a B4XTable.
I am running thru B4A-Bridge to try and troubleshoot this.
On my SM-G998U all works as expected regardless of how the project is compiled.
On a SM-A125U running in Debug mode everything works as expected but in Release mode when I open this activity it crashes with the following:
Logger connected to: samsung SM-A125U
b4xfloattextfield_settext (java line: 536)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String anywheresoftware.b4a.objects.B4XViewWrapper.getText()' on a null object reference
at coldtech.ctx.b4xfloattextfield._settext(b4xfloattextfield.java:536)
at coldtech.ctx.listhandler._onload(listhandler.java:1859)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1178)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Just a guess: debug mode is a bit slower than release. If you have async methods in your code or libraries, some variable or object may not be initialized in time they are used in release mode. Try adding Sleep(200) before operations you suspect to fail. If this helps, adjust the interval later. Try-Catch with Toast messages can also help to locate the fault point.
Removing those eliminated the above error but then I started getting a MDBottomAppBar exception, which I solved by checking if it is initialized and performing a sleep as Gandalf recommended.
Probably a subtle timing thing. The display is rendered, and so the views are created, on a different thread to your main thread so if you are doing potentially 'naughty' things it may or may not cause an error depending on the interleaving of the threads.