Reputation: 79
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.
Upvotes: 3
Views: 5409
Reputation: 987
I used a different approach to cope with this error. In my case I have the receiver core component called com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver
without the property exported. Where? I didn't know.
So I found inside my plugin folder which it exists after running flutter pub get. After searching I read the manifest of flutter_local_notifications version "4.0.1+2" and see the error. Therefore, I added android:exported="true" on it and retry the flutter run on my emulator.
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
This is not a solution because I have to rewrite this manifest after cleaning the project.
Upvotes: 0
Reputation: 1
just follow steps :
1 set targetSdkVersion and compileSdkVersion 32
2 open AndroidManifest.xml , in application tag add this -
usesCleartextTraffic="true"
androidSupportRtl="true"
3 set android:exported="true" in activity
Upvotes: 0
Reputation: 33
upgrade your project to the most recent flutter version.
Upgrade your dependancies, seach tags in all AndroidManifest.xml files, also in your manifest dependancies files. and change
service ....></service>
or
<service .... android:exported="false"></service>
to
<service .... android:exported="true"></service>
Upvotes: 1
Reputation: 1201
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:
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>
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.).
Upvotes: 3