Android API 31 level causes error for Flutter local notifications in the app - flutter

As per Google's policy, I updated my targetSdkVersion and compileSdkVersion to 31. But I noticed that the Flutter local notification package now throws error for incoming messages as below:
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.
I went through all the Stack overflow answers related to this error and made following changes:
Added below Java and Kotlin dependencies in build.gradle file:build.gradle file
Added this receiver below activity tag:
Receiver tag
Added exported flag under activity tag:
Exported flag
Updated gradle version to latest in gradle-wrapper.properties:
Latest gradle version
I am not using any PendingIntent in my code, and simulating app on simulator with API 31 level. Could someone please help me in resolving this issue with message notifications?

Related

How to fix when I started up the Android Studio and Generate the Emulator, but there is 6 errors

6 issues were found when checking AAR metadata:
Dependency 'androidx.appcompat:appcompat-resources:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.appcompat:appcompat:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.activity:activity:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.core:core:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.core:core-ktx:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.annotation:annotation-experimental:1.3.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
6 issues were found when checking AAR metadata:
Dependency 'androidx.appcompat:appcompat-resources:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.appcompat:appcompat:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.activity:activity:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.core:core:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.core:core-ktx:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Dependency 'androidx.annotation:annotation-experimental:1.3.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs.
:app is currently compiled against android-32.
Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33.
Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).
Edit 3: Just discovered a likely more safe and complete way to do this:
Changing Sdk Version using Android Studio menus
If using Mac, go to File -> Project Structure.
Under Modules, look for app, and then look for the tab labeled Properties. The first option, called Compile Sdk version, is the error. You want to change the compile Sdk version from 32 to 33.
Original Post:
I do! Just figured it out myself. See image below for visual guidance exact locations in Android Studio.
Partial Screenshot of what to update
In the directory, find Gradle Scripts, and in Gradle Scripts find "build.gradle (Module :app)".
Within that, change compileSdk from 32 to 33, and change targetSdk from 32 to 33. Look through build.gradle for anything else that might need updating number-wise.
Then click Sync Now at the top of the code editor.
I ran into this problem right away on the default "Hello World" app, so if you find it early it may be more helpful. I don't know how difficult it is to fix when something more complex has been put in place. I hope I help at least a little!
From,
A brand new student learning Android. :)

Ionic Capacitor : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE

I’m having this issue because of the minimum target SDK 31 update for the Play Store
I’ve had the App working well, I changed the TargetSDK in the gradle variables file and I’m getting this error :
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.
Here’s the List of My Plugins :
(npx cap ls)
#capacitor-community/admob#3.2.0
#capacitor/app#1.1.1
#capacitor/haptics#1.1.4
#capacitor/keyboard#1.2.2
#capacitor/push-notifications#1.0.9
#capacitor/splash-screen#1.2.2
#capacitor/status-bar#1.0.8
#codetrix-studio/capacitor-google-auth#3.1.4
[info] Listing plugins for web is not possible.
I’ve read That I need to upgrade some plugins but i don’t know which ones
Can you please help me
To properly support SDK 31/32 you have to upgrade to capacitor 4.
Run npm i #capacitor/cli#latest. And then run npx cap migrate. That will update all capacitor dependencies and plugins to version 4 and make required changes to your native projects.

Flutter build failing after switching from compileSdkVersion 30 to compileSdkVersion 31

I had an old project which I had released and the person I made it for wanted me to add notifications. I added the flutter messaging and flutter local notifications and updated the firebase dependencies accordingly. After this I tried to run the app but it said you have to upgrade the compileSdkVersion to 31. But this resulted in the following error.
Up till now I have tried upgrading my dart sdk, deleting the pubspec.lock file and running it again. I have also tried importing my project again after reinstalling flutter. The error just won't go away.

My flutter app is not displaying in chrome when launched with no errors and when run to my android it gives me errors

The error says the number of method references in dex file cannot exceed 64.
I have tried changing the emulator I used and also changed how I launch the app, but no display still.
Try setting
minSdkVersion = 21
or higher in your gradle file and tell us if it fixes
The problem is with the multidex file of android.
Setting minSdkVersion to 21 or higher enable by default multidex. If you want to keep down the minsdk, you could also follow the answer that was given here:
How to enable multidexing with the new Android Multidex support library

Firebase for Flutter sign-in build failure

I have been following the Firebase for Flutter tutorial with success until I reach "Set up Firebase Integration". When I relaunch the app on my phone the build fails with the following exception:
Note:
/Users/williamdevore/.pub-cache/hosted/pub.dartlang.org/firebase_storage-0.0.2/android/src/main/java/io/flutter/plugins/firebase/storage/FirebaseStoragePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. /Users/williamdevore/.pub-cache/hosted/pub.dartlang.org/google_sign_in-0.0.6/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java:30:
error: cannot find symbol import
io.flutter.app.FlutterFragmentActivity;
^ symbol: class FlutterFragmentActivity location: package io.flutter.app
/Users/williamdevore/.pub-cache/hosted/pub.dartlang.org/google_sign_in-0.0.6/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java:98:
error: cannot find symbol
+ FlutterFragmentActivity.class.getName());
^ symbol: class FlutterFragmentActivity location: class GoogleSignInPlugin 2 errors
FAILURE: Build failed with an exception.
Flutter doctor says everything is fine for Android. I have the latest "everything". I was able to setup the google-services json file and use the Firebase console with no problems.
I followed the instructions for modifying the build.gradle files exactly--twice!.
Is there some of other step I should be doing outside of the Flutter tutorial that is specific for Android, perhaps Brew or cocoapods maybe?
It looks like you might have an older version of Flutter that doesn't match the Google Sign In plugin version you're using. Right now the plugins aren't declaring which versions of Flutter they require (but that may change in the future).
Does running flutter update get you past this error? If not, try running flutter doctor and see how old your Flutter SDK is. You want it to include the commit b4ba972bf394a2269824e1eadaa1627bbc872d4b, so it should be a few days old at most.
You should replace FlutterActivity with FlutterFragmentActivity in the two places it appears in your MainActivity.java. (This won't be necessary in the next Google Sign In plugin update; see issue 10690.)