bug: @capacitor/share PendingIntent IllegalArgumentException
See original GitHub issueBug Report
Capacitor Version
@capacitor/cli: 3.4.0 @capacitor/core: 3.4.0 @capacitor/android: 3.4.0 @capacitor/ios: 3.4.0 @capacitor/share: 1.1.1
Platform(s)
Android
Current Behavior
Calling the share function Share.share({})
via import { Share } from '@capacitor/share';
crashes the Android app.
E/Capacitor: Serious error executing plugin
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:592)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.IllegalArgumentException: com.XXXX.XXXX: 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:382)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
at com.capacitorjs.plugins.share.SharePlugin.share(SharePlugin.java:115)
... 9 more
Expected Behavior
It should not crash when target >= 31.
Code Reproduction
js:
Share.share({
title: 'See cool stuff',
text: 'Really awesome thing you need to see right meow',
url: 'http://ionicframework.com/',
dialogTitle: 'Share with buddies',
});
variables.gradle
targetSdkVersion = 31
Additional Context
https://developer.android.com/about/versions/12/behavior-changes-12 https://developer.android.com/reference/android/app/PendingIntent#FLAG_IMMUTABLE https://github.com/qiscus/qiscus-sdk-android/releases/tag/1.3.35
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
[Android S] java.lang.IllegalArgumentException [194108978]
IllegalArgumentException : com.app. ... The bug happened even when no pending intent was used for notification or when the Work component was not...
Read more >Android 12 run: Fatal Exception Targeting S+ (version 31 and ...
When I try to run my app on Android 12, I get this error in Android Studio run ... checkFlags(PendingIntent.java:382) at android.app.
Read more >How to resolve "Missing PendingIntent mutability flag" lint ...
I tried this using -alpha04 and still receiving the error. I only have 1 PendingIntent for my application and not able move forward...
Read more >Bug - Android 12 App crashes on startup due to error with ...
IllegalArgumentException : com.Guambo.GooRunner: Targeting S+ (version 31 and ... play-services-ads has a bug using PendingIntent without.
Read more >PendingIntent - Android Developers
By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified as if the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks for the issue, but it’s already reported on the plugins repository https://github.com/ionic-team/capacitor-plugins/issues/690
capacitor will officially support to target SDK 31 on the next 4.0.0 release and plugins will also be updated to target SDK 31 and all the issues that targeting SDK 31 causes will be fixed.
+1