You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Already on GitHub?
Sign in
to your account
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.
#1463
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.
#1463
kdqtech
opened this issue
Dec 7, 2022
· 18 comments
What happened?
Android 12 recently made it mandatory to use FLAG_IMMUTABLE or FLAG_MUTABLE, this makes the application crash as soon as it's opened.
This is happening when I change my targetSdkversion to 31 / 33
with Previous version compileSdkVersion and targetSdkVersion it was working fine
After changing compileSdkVersion and targetSdkVersion as below it is not working
Steps to reproduce?
1. Create react native project with
2. Intigrate onesignal library
3. run the app
What did you expect to happen?
I expected that app should work properly and should not crash
React Native OneSignal SDK version
api 'com.onesignal:OneSignal:4.8.2'
Which platform(s) are affected?
Android
Relevant log output
FATAL EXCEPTION: pool-4-thread-1
Process: com.packagename, PID: 21167
java.lang.IllegalArgumentException: com.packagename: 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 androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:285)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:158)
at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:185)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:103)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Code of Conduct
I agree to follow this project's Code of Conduct
@kdqtech
Can you confirm this is correct from your orignal post?
"react-native-onesignal": "4.5.0",
We address Android 12 (targetSdkversion: 31) in the react-native-onesignal 4.0.0 release.
@jkasten2
First of all Thank you so much for your quick response
We were using "react-native-onesignal": "^4.3.11" when the targetSdkVersion was 30. Everything was working then. Since the time we have changed the targetSdkVersion to 31, the one signal library is not working in both cases (version 4.3.11 and version 4.5.0). To validate the issue, I removed onsignal from my project completely and it worked.
let me add here my all the steps and code here when i have integrate onesignal first time in my App
When i have integrated onesignal first time i have follow below steps
The version of "react-native-onesignal": "^4.3.11",
In settings.gradle
include ':react-native-onesignal'
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
In android/app/build.gradle
manifestPlaceholders = [
appAuthRedirectScheme: 'myappname,
onesignal_app_id: 'XXX', //'XXX' is my onesignal app id that get from onesignal account
onesignal_google_project_number: 'REMOTE'
And then i am just using my above oneSignalToken in my some of axious api
@kdqtech Thanks for the details. I see in your case the crash is coming from androidx.work.impl.utils.ForceStopRunnable based on your original post. This means for some reason there is an old version of androidx.work:work-runtime being included in your app.
To find out what you can try running one of these to see all the gradle dependences for your Android app.
./gradlew build --scan
./gradlew -q dependencies
You can then look up the tree to see what is including work-runtime and update the react native plugin.
If the above doesn't help you could just force update androidx.work:work-runtime by adding it to your build.gradle:
dependencies {
// Keep other dependencies you have
implementation('androidx.work:work-runtime:2.7.1')
However it is better to find the root plugin downgrading so you don't have to keep this work around.
@kdqtech Can you confirm this is correct from your orignal post?
"react-native-onesignal": "4.5.0",
We address Android 12 (targetSdkversion: 31) in the react-native-onesignal 4.0.0 release.
Well tks alot, with "react-native-onesignal": "^4.5.0", the notification is working, and ive added the implementation('androidx.work:work-runtime:2.7.1') too
Thanks @jkasten2 it is resolved by adding anyone option from below in android/app/build.gradle
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.7.1' }
def work_version = "2.7.1"
// Force WorkManager 2.7.1 for transitive dependency
implementation("androidx.work:work-runtime:$work_version") {
force = true
Your commands helped me a lot !!
dprajapati1179, ShitalMaskr, UsamaIrfan, jaroslav009, Dipak-Complitech, morellexf13, junaid900, filipelsimoes, and BlaShadow reacted with thumbs down emojidaviluisb reacted with heart emojiAll reactions
I won't recommend force locking like this:
configurations.all {
resolutionStrategy { force 'androidx.work:work-runtime:2.7.1' }
As this could break things in the future for you, if OneSignal or another library requires a newer version.
This well tell gradle that you require at least this version, but something can still upgrade it in your app if it is a requirement.
On S.O Windows 11: "PS D:\SEA\Cofre\A_Alfa\ProjSEA\Flutter\todo> flutter doctor -v
[√] Flutter (Channel stable, 3.7.7, on Microsoft Windows [versÆo 10.0.22000.1696], locale pt-BR)
• Flutter version 3.7.7 on channel stable at D:\SEA\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2ad6cd72c0 (12 days ago), 2023-03-08 09:41:59 -0800
• Engine revision 1837b5be5f
• Dart version 2.19.4
• DevTools version 2.20.1
[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at C:\Users\sea-5\AppData\Local\Android\sdk
• Platform android-33-ext4, build-tools 33.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.5.33424.131
• Windows 10 SDK version 10.0.22000.0
[√] VS Code (version 1.76.2)
• VS Code at C:\Users\sea-5\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.60.0
[√] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [versÆo 10.0.22000.1696]
• Edge (web) • edge • web-javascript • Microsoft Edge 111.0.1661.44
[√] HTTP Host Availability
• All required HTTP hosts are available"
And On method: " Future displayNotification(
{required String title, required String body}) async {
print("doing test");
var androidPlatformChannelSpecifics = const AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
importance: Importance.max, priority: Priority.high);
var platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
title,
body,
platformChannelSpecifics,
payload: 'Default_Sound', After: "await flutterLocalNotificationsPlugin.show()
title,
body,
platformChannelSpecifics,
payload: 'Default_Sound', I get:
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/MethodChannel#dexterous.com/flutter/local_notifications(13731): 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.
Hi @iamrohitagg, this issue was closed by the original poster as they were able to resolve it. If you are on version 4.1.0, you will need to update. We made the fix to support Android 12 in version 4.3.0 of the react-native-onesignal SDK. Please update to that version or above.
Hi @SEAFromJahu I don't see any mention of onesignal in your post. The message seems to come from flutter/local_notifications
I'm using the react-native-share package to share a component as an image. It works fine on Android versions below 33, but on Android 33, it throws an error: 'Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a Pending Intent.' How can I fix this issue?
After updating react-native-share package its says,
react-native-share compile SDK Version is not specified. Please add it to build.gradle.
What went wrong: A problem occurred evaluating project ':react-native-share'.
Could not set unknown property 'namespace' for extension 'android' of type com.android.build.gradle.LibraryExtension.
FATAL EXCEPTION: main
Process: ru.ironcodes.islamicwikipedia, PID: 6914
java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.ironcodes.islamicwikipedia/ru.ironcodes.islamicwikipedia.MainActivity}: java.lang.IllegalArgumentException: ru.ironcodes.islamicwikipedia: 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.ActivityThread.performLaunchActivity(ActivityThread.java:3760)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3934)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2287)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8261)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.IllegalArgumentException: ru.ironcodes.islamicwikipedia: 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:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at ru.ironcodes.islamicwikipedia.AlarmReceiver.setAlarm(AlarmReceiver.java:29)
at ru.ironcodes.islamicwikipedia.MainActivity.onCreate(MainActivity.java:109)
at android.app.Activity.performCreate(Activity.java:8238)
at android.app.Activity.performCreate(Activity.java:8206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3733)
... 12 more
me also have same issue how to solve it for sketchware development
java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.ironcodes.islamicwikipedia/ru.ironcodes.islamicwikipedia.MainActivity}: java.lang.IllegalArgumentException: ru.ironcodes.islamicwikipedia: 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.ActivityThread.performLaunchActivity(ActivityThread.java:3760)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3934)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2287)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8261)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.IllegalArgumentException: ru.ironcodes.islamicwikipedia: 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:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at ru.ironcodes.islamicwikipedia.AlarmReceiver.setAlarm(AlarmReceiver.java:29)
at ru.ironcodes.islamicwikipedia.MainActivity.onCreate(MainActivity.java:109)
at android.app.Activity.performCreate(Activity.java:8238)
at android.app.Activity.performCreate(Activity.java:8206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3733)
... 12 more