Android Question SDK31 + java.lang.reflect.InvocationTargetException

Cainsoft

Member
Licensed User
Longtime User
Hi all,
I am upgrading a simple app to targetSDK 31. With SDK 30 everything works correctly. But with version 31, I get the following error in the Google Dev console pre-launch report:
java.lang.reflect.InvocationTargetException:
FATAL EXCEPTION: main
Process: com.vanvalasztaskft.gusto, PID: 24245
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at com.vanvalasztaskft.gusto.nb6._build(nb6.java:137)
    at com.vanvalasztaskft.gusto.main._activity_resume(main.java:437)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at com.vanvalasztaskft.gusto.main.afterFirstLayout(main.java:112)
    at com.vanvalasztaskft.gusto.main.access$000(main.java:18)
    at com.vanvalasztaskft.gusto.main$WaitForLayout.run(main.java:84)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7839)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.IllegalArgumentException: com.vanvalasztaskft.gusto: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
    at android.app.PendingIntent.getActivity(PendingIntent.java:444)
    at android.app.PendingIntent.getActivity(PendingIntent.java:408)
    ... 18 more

I found a thread, but the 11.81 core did not help me: [ SOLVED] Target SDK 31 widget crash

Can anyone help me with a solution?

Thank you!
 

ilpesce

Member
Licensed User
Longtime User
I solved many problems with SDK31 by asking for this permission:
 
Upvote 0

Cainsoft

Member
Licensed User
Longtime User
Hi, I don't quite understand this thread, why should I request this special permission ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…