Android Question java.lang.RuntimeException: java.lang.reflect.InvocationTargetException on LoadLayout

Star-Dust

Expert
Licensed User
Longtime User
Good morning to all,

I found a strange error that my App presents only on a device that has Android 9. On all the other devices I've tried it has not generated any errors. I don't know if it's related to the Android version or anything else

When it exits the App (Pause) and re-enters it goes to Activity_Create and at the time of loading the LoadLauout goes into error.

In that Layout there is a Custom View. But it only works properly the first time. As soon as you return, it generates the error you find in the spoiler.

What could it be?

P.S. In the past I have faced such a thing and the problem was that I did not require runtime permissions to read files in the root, but in this case it is not so


--------- beginning of system
--------- beginning of crash
--------- beginning of main
~i:*** Service (starter) Create ***
~i:** Service (starter) Start **
~i:*** Service (localizzazione) Create ***
~i:** Service (localizzazione) Start **
~l114718594:false
~l214718597:Attivato Wifi
~i:** Activity (main) Create, isFirst = true **
~l311900545:Load: temp.s3db
~e:main_activity_create (java line: 371)
~e:java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
~e: at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
~e: at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
~e: at it.tecnomedia.enotes.main._activity_create(main.java:371)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
~e: at it.tecnomedia.enotes.main.afterFirstLayout(main.java:104)
~e: at it.tecnomedia.enotes.main.access$000(main.java:17)
~e: at it.tecnomedia.enotes.main$WaitForLayout.run(main.java:82)
~e: at android.os.Handler.handleCallback(Handler.java:873)
~e: at android.os.Handler.dispatchMessage(Handler.java:99)
~e: at android.os.Looper.loop(Looper.java:193)
~e: at android.app.ActivityThread.main(ActivityThread.java:6912)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
~e:Caused by: java.lang.reflect.InvocationTargetException
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
~e: at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
~e: ... 14 more
~e:Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
~e: at it.tecnomedia.enotes.ordinazioneview._vvvv0(ordinazioneview.java:516)
~e: at it.tecnomedia.enotes.ordinazioneview._initialize(ordinazioneview.java:394)
~e: ... 17 more
~i:** Service (localizzazione) Destroy **
~i:*** Service (starter) Create ***
~i:** Service (starter) Start **
~i:*** Service (localizzazione) Create ***
~i:** Service (localizzazione) Start **
~l114718594:false
~l214718597:Attivato Wifi
~i:** Activity (main) Create, isFirst = true **
~l311900545:Load: temp.s3db
~e:main_activity_create (java line: 371)
~e:java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
~e: at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
~e: at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
~e: at it.tecnomedia.enotes.main._activity_create(main.java:371)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
~e: at it.tecnomedia.enotes.main.afterFirstLayout(main.java:104)
~e: at it.tecnomedia.enotes.main.access$000(main.java:17)
~e: at it.tecnomedia.enotes.main$WaitForLayout.run(main.java:82)
~e: at android.os.Handler.handleCallback(Handler.java:873)
~e: at android.os.Handler.dispatchMessage(Handler.java:99)
~e: at android.os.Looper.loop(Looper.java:193)
~e: at android.app.ActivityThread.main(ActivityThread.java:6912)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
~e:Caused by: java.lang.reflect.InvocationTargetException
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
~e: at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
~e: ... 14 more
~e:Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
~e: at it.tecnomedia.enotes.ordinazioneview._vvvv0(ordinazioneview.java:516)
~e: at it.tecnomedia.enotes.ordinazioneview._initialize(ordinazioneview.java:394)
~e: ... 17 more
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at it.tecnomedia.enotes.main._activity_create(main.java:371)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at it.tecnomedia.enotes.main.afterFirstLayout(main.java:104)
at it.tecnomedia.enotes.main.access$000(main.java:17)
at it.tecnomedia.enotes.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6912)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 14 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
at it.tecnomedia.enotes.ordinazioneview._vvvv0(ordinazioneview.java:516)
at it.tecnomedia.enotes.ordinazioneview._initialize(ordinazioneview.java:394)
... 17 more

(RuntimeException) java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
The important part of this error message is:

B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
at it.tecnomedia.enotes.ordinazioneview._vvvv0(ordinazioneview.java:516)
at it.tecnomedia.enotes.ordinazioneview._initialize(ordinazioneview.java:394)

I cannot say anything else without seeing the relevant code...

Add a few log messages to better understand what happens there (and run in non-obfuscated mode).
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Thanks Erel, this was already a lot of help, I looked at the error.

It is an access to a database:
B4X:
Operatori=DB.ExecQuerySingleResult("SELECT operatori FROM rapporto WHERE ID=1").Replace("|",CrLf)
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Thank's
 
Upvote 0
Top