Skip to content
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

bug: @capacitor/share PendingIntent IllegalArgumentException #5392

Closed
BuffMcBigHuge opened this issue Jan 25, 2022 · 5 comments
Closed

bug: @capacitor/share PendingIntent IllegalArgumentException #5392

BuffMcBigHuge opened this issue Jan 25, 2022 · 5 comments

Comments

@BuffMcBigHuge
Copy link

BuffMcBigHuge commented Jan 25, 2022

Bug 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

@jcesarmobile
Copy link
Member

thanks for the issue, but it's already reported on the plugins repository
ionic-team/capacitor-plugins#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.

@BuffMcBigHuge
Copy link
Author

Ah didn't realize there was a separate issue section for plugins. Thanks 👍

@nprather
Copy link

Hi, I've run into this bug. Looks like compacitor 4.0 is in beta at the moment.

As a workaround until it's live, can you tell me where to set the "FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent" ?

@mirko77
Copy link

mirko77 commented Jun 22, 2022

Same issue here

@dgreasi
Copy link

dgreasi commented Jul 26, 2022

+1

@ionic-team ionic-team locked as resolved and limited conversation to collaborators Jul 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants