'Flutter unable to build app for android 12
I am trying to build my Flutter App to support Android 12. It works fine up to Android 11, but is not supporting Android 12. I trying to add android:exported="true" or "false" but not working. If someone know please help
Error logs
Error: ADB exited with exit code 1 Performing Streamed Install
adb: failed to install /Users/shrikrishna/Manoj/Projects/Flutter/Myapp/build/app/outputs/flutter-apk/app.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl158598875.tmp/base.apk (at Binary XML file line #1230): com.dooboolab.TauEngine.FlautoBackgroundAudioService: 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 sdk gphone64 x86 64.
Solution 1:[1]
You need to set the android:exported="true" or "false" on every activity, services, or broadcast receiver that using any intent-filter. Please note, if you have multiple dependencies, and in these dependencies if they have their own activity, services, or broadcast receiver, we also need to add these android:exported also on each of it.
But obviously, some dependencies may be not yet updated to comply with this one. so for now we can solve it by adding it in our own app Manifest.
to do this:
1. Check for merged manifest
First build the app, and then check for the merged manifest on the build folder. This usually on directory ./build/app/intermediates/merged_manifest/debug/out/AndroidManifest.xml
Open it, and find any tag <intent-filter> on this file. and note the activity, service or broadcast class name. foe example:
        <receiver
            android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver" >
            <intent-filter>
                ....
            </intent-filter>
        </receiver>
2. Modify our app Manifest.
Open your project app manifest, and add tools namespace on the manifest tag. xmlns:tools="http://schemas.android.com/tools"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    xmlns:tools="http://schemas.android.com/tools">
Then add these class on the manifest with the additional attribute android:exported="false" and make sure to add tools:node="merge" on it also. For example:
        <receiver
           android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver" 
           android:exported="false"
           tools:node="merge" />
you dont need to add the other attribute or intent filter on your Project Manifest, since its already added on the plugins Manifest file. you only need to add these exported and tools:node="merge" to make the manifest attributes and value to be merged.
Then Lastly, run it locally first and make sure all of the Activity/services/broadcast receiver with intent-filter is having these attributes (NOTE: tools:node attribute will be not present on the merged Manifest.).
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 | 
