How to find the culprit in an Android Studio logcat

60 Views Asked by At

If made a cordova app with several plugins. One of them being a chromecast plugin. Upon connecting to a receiver the app stops (message: ... has stopped). In the logcat I see a stacktrace leading to this crash. My question: how to read this stacktrace and find the exact file that causes the error?

2023-12-18 09:35:57.526 2446-2446 AndroidRuntime E FATAL EXCEPTION: main
Process: <APPNAME>, PID: 2446
java.lang.IllegalArgumentException: <APPNAME>: 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:401)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:671)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:658)
    at com.google.android.gms.internal.cast.zzah.zza(Unknown Source:32)
    at com.google.android.gms.cast.framework.CastSession$zzb.onResult(Unknown Source:12)
    at com.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(com.google.android.gms:play-services-base@@18.1.0:6)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7941)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)

I could easily solve this if I would know which file is causing the issue. But I don't see any file that I can edit.

How to read this stacktrace and open the exact file that is causing this error?

1

There are 1 best solutions below

0
Cloverleaf On

The second line says: You still have an outdated call of a PendingIntent in your code, probably something like:

PendingIntent mPendingIntent = PendingIntent.getActivity(this, 0, mIntent, 0);

Since API 31, the fourth argument must be set, e.g.

PendingIntent mPendingIntent = PendingIntent.getActivity(this, 0, mIntent, PendingIntent.FLAG_IMMUTABLE);

The file name is not mentioned in the error report. So search and check all your PendingIntent.getActivity in your project.