-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update launcher activity attribute to Android 12 #2074
Conversation
This can be resolved by the app side temporarily: <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" ...>
<application ...>
<activity-alias
android:name="leakcanary.internal.activity.LeakLauncherActivity"
android:exported="true"
android:targetActivity="leakcanary.internal.activity.LeakActivity"
tools:node="merge" />
</application>
</manifest> However, it will still crash because o thef Android-12-targeting PendingInent API: E/AndroidRuntime: FATAL EXCEPTION: IntentService[HeapAnalyzerService]
Process: net.imknown.android.forefrontinfo.debug:leakcanary, PID: 6854
java.lang.IllegalArgumentException: net.imknown.android.forefrontinfo.debug: Targeting S+ (version 10000 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:367)
at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:452)
at android.app.PendingIntent.getActivity(PendingIntent.java:437)
at android.app.PendingIntent.getActivity(PendingIntent.java:401)
at leakcanary.internal.activity.LeakActivity$Companion.createPendingIntent(LeakActivity.kt:181)
at leakcanary.DefaultOnHeapAnalyzedListener.showNotification(DefaultOnHeapAnalyzedListener.kt:74)
at leakcanary.DefaultOnHeapAnalyzedListener.onHeapAnalyzed(DefaultOnHeapAnalyzedListener.kt:66)
at leakcanary.internal.HeapAnalyzerService.onHandleIntentInForeground(HeapAnalyzerService.kt:73)
at leakcanary.internal.ForegroundService.onHandleIntent(ForegroundService.kt:55)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:78)
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.os.HandlerThread.run(HandlerThread.java:67) leakcanary/leakcanary-android-core/src/main/java/leakcanary/internal/activity/LeakActivity.kt Lines 174 to 182 in 438aa49
So, it may be: intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or PendingIntent.FLAG_IMMUTABLE |
I'm going to merge this. @imknown you are saying there's still going to be a crash even after exported is merged in, right? |
@pyricau Yes. Crash will happen after dumping. |
To be able to target Android 12 all activities that use intent filters must declare the
android:exported
attribute.Reference: https://developer.android.com/about/versions/12/behavior-changes-12#exported
This pull request adds the attribute on
LeakLauncherActivity
.Without it, apps that have a dependency on LeakCanary will not be able to target Android 12.
I got the following error when trying to build an app that depends on LeakCanary targeting Android 12: