Home > Blockchain >  android:export when migrating to Android 12 in Flutter AndroidManifest
android:export when migrating to Android 12 in Flutter AndroidManifest

Time:01-11

I'm migrating my flutter app to Android 12 and I don't know where exactly I've to put the android:export lines in my AndroidManifest. I've tries several options but always the console throws me an error about this. This is my AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.atgapp.atgapp">
   <application
        android:label="atgapp"
        android:name="${applicationName}"
        android:icon="@mipmap/icono"
        android:exported="true">
       <meta-data
           android:name="com.google.firebase.messaging.default_notification_icon"
           android:resource="@mipmap/icon" />
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
       <service
           android:name=".MyFirebaseMessagingService">
           <intent-filter>
               <action android:name="com.google.firebase.MESSAGING_EVENT" />
           </intent-filter>
       </service>
    </application>
</manifest>

Thank you for your help

CodePudding user response:

Just update your Service tag

<service
    android:name=".MyFirebaseMessagingService"
    android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
</service>

CodePudding user response:

First, if you open the app in Android Studio and go through your Manifest you should find warnings for exporting services/activities, fix those by adding the suggested.

After, you should create a API 31 emulator (with Android 12) and try running your app, you will probably receive an error caused by some library that is not updated, like the following:

Installation did not succeed. The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

List of apks: [0] 'C:\Users\------\Desktop-----\=====\mobile\build\outputs\apk\debug\mobile-debug.apk' Installation failed due to: 'INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1980686865.tmp/base.apk (at Binary XML file line #294): com.instacart.library.truetime.BootCompletedBroadcastReceiver: Targeting S (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'

for the example above, the library TrueTime is outdated, updating it resolved the problem.

  • Related