Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

SDK 31 above requires FLAG_IMMUTABLE or FLAG_MUTABLE PendingIntent. #166

Open
seilron opened this issue Feb 20, 2023 · 6 comments
Open

SDK 31 above requires FLAG_IMMUTABLE or FLAG_MUTABLE PendingIntent. #166

seilron opened this issue Feb 20, 2023 · 6 comments
Labels

Comments

@seilron
Copy link

seilron commented Feb 20, 2023

Description of the bug

2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime java.lang.IllegalArgumentException: com.com2us.futurecpb.android.google.global.normal: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime 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.
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at com.yasirkula.unity.NativeShareBroadcastListener.Initialize(NativeShareBroadcastListener.java:32)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at com.yasirkula.unity.NativeShareFragment.onCreate(NativeShareFragment.java:42)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.Fragment.performCreate(Fragment.java:2486)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1261)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2431)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2210)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2166)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2067)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.FragmentManagerImpl$1.run(FragmentManager.java:742)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.os.Handler.handleCallback(Handler.java:938)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.os.Looper.loopOnce(Looper.java:226)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.os.Looper.loop(Looper.java:313)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:8669)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
2023/02/20 17:23:03.310 21577 21577 Error AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Reproduction steps

need Android OS 12~
Build SDK 31~
Excute and Share

Platform specs

Unity version : 2021.3.16f1
Platform : Android
Device : Android OS 12~
Plugin Download Path - Github

@seilron seilron added the bug label Feb 20, 2023
@yasirkula
Copy link
Owner

Can you delete NativeShare from your project, comment out NativeShare related user code and build again? "com.com2us.futurecpb.android.google.global.normal" isn't a part of this plugin.

@EduFeArn
Copy link

Hi, I am having the same issue see details bellow:

FATAL EXCEPTION: main
Process: com.EduFeArn.EduFeArnEduGames, PID: 5408

java.lang.IllegalArgumentException: com.EduFeArn.EduFeArnEduGames: 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.yasirkula.unity.NativeShareBroadcastListener.Initialize(NativeShareBroadcastListener.java:33)
at com.yasirkula.unity.NativeShareFragment.onCreate(NativeShareFragment.java:42)
at android.app.Fragment.performCreate(Fragment.java:2486)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1261)
at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2431)
at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2210)
at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2166)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2067)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:742)
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.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Reproduction
need Android OS 12
Build SDK 32
At runtime when attempting to Share

Platform
Unity version : 2020.3.41f1
Platform : Android
Device : Android OS 12

Have confirmed that building and targeting any API level below 31 does not cause this to happen

@yasirkula
Copy link
Owner

I'm passing FLAG_MUTABLE's hardcoded value which is why I'm having trouble figuring out this issue:

if( Build.VERSION.SDK_INT >= 31 )
{
// We must mark PendingIntent as either mutable or immutable on Android 12+
// Maybe FLAG_IMMUTABLE is sufficient but the pre-31 default value was implicitly mutable and I don't trust
// all social apps to work correctly on Android 12+ (API 31+) if I set it to FLAG_IMMUTABLE
//pendingIntentFlags |= PendingIntent.FLAG_MUTABLE;
pendingIntentFlags |= 1 << 25; // Hardcoded value of PendingIntent.FLAG_MUTABLE (when compiling with an older SDK version)
}

@EduFeArn
Copy link

I do apologize for any inconvenience, seems the issue was on my side removed and reimported the plug-in and is working.
Recently did a big upgrade in unity versions, the version of the plug-in was also most likely out of date and I did not notice,
Thanks again for the help and again apologies.

@yasirkula
Copy link
Owner

Happy to help :D

@yasirkula
Copy link
Owner

Reopened because @seilron hasn't responded yet. Please upgrade the plugin via GitHub and try again.

@yasirkula yasirkula reopened this Feb 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants