'Flutter Android 12 install error when using intent-filter
I'm struggling with the error below.
adb: failed to install F:\xxx\src\FlutterDemoApp\FlutterDemoApp\build\app\outputs\flutter-apk\app.
apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1942767517.tmp/base.apk (at Binary XML file line #102):
com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
Error launching application on Pixel 4 XL.
As I found at Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present] and Android Studio error: "Manifest merger failed: Apps targeting Android 12" this is simply a matter of adding android:exported="true" to android/app/src/main/AndroidManifest.xml
But the issue is it is already there in my environment and I still get the error.
Am I missing something else?
Solution 1:[1]
I tried cleaning the project & changing package names to lowercase as advised in the comments. But nothing worked. Below is what worked for me. Hope somebody fined this helpful.
I had to add Multi Dex support to my build.gradle
defaultConfig {
applicationId "com.example.demo_app"
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled = true //?This
}
and
dependencies {
implementation("androidx.multidex:multidex:2.0.1")//?This
implementation 'org.altbeacon:android-beacon-library:2.19'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Not exactly sure why this work, but you can read more here https://developer.android.com/studio/build/multidex
Solution 2:[2]
Also make this in note,
Starting from Android 12 (SDK 31) and when using intent-filter, the attribut android:exported must be set explicitly to false or true. Without this attribut the application wouldn't be able to be installed. References:
Resource: (contains the warning about installing an application without this attribut on Android 12 or higher)
When a new flutter project
is created the default AndroidManifest.xml
should contain this attribute
set to true
as the intent
is a android.intent.category.LAUNCHER:
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="..."
android:hardwareAccelerated="true"
android:exported="true" <== SHOULD BE ADDED
android:windowSoftInputMode="adjustResize">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dileepa Rathnayake |
Solution 2 | Manishyadav |