Abir Ahsan
Abir Ahsan

Reputation: 3049

Flutter : INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI

My flutter app isn't install on Android 12 version. I tried with android:exported, but nothing work. It's show me this type of error-

✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...                 3.3s
Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install /Users/abir/Documents/Office
Work/MediMate-App-Old-Version/build/app/outputs/flutter-apk/app.apk: Failure
[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI:
/data/app/vmdl489268217.tmp/base.apk (at Binary XML file line #125):
io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: 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.

Here is my AndroidManifest.xml file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="care.example.health">
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->
    <uses-permission android:name="android.permission.BLUETOOTH" />

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.VIBRATE" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
   <application
        android:label="example"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:exported="true"
            android:name=".MainActivity"
            
            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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter 
                android:exported="false">
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter 
                android:exported="false">
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
       
    </application>
</manifest>

What did I miss ?

Upvotes: 9

Views: 12687

Answers (6)

Ayyaz Shair
Ayyaz Shair

Reputation: 620

if none of the solutions above worked, use the forked version of firebase_messaging: ^6.0.16 with android:exported="false".

  firebase_messaging:
    git:
      url: https://github.com/itsAyyazdev/firebase_messaging.git

Upvotes: 1

Musfiq Shanta
Musfiq Shanta

Reputation: 1615

very simple add this line of code android:exported="true" AndroidManifest.xml

location android/app/src/main/AndroidManifest.xmlenter image description here

Upvotes: 3

Rainbowp0ny
Rainbowp0ny

Reputation: 179

If you get this error message when you try to run your flutter app on android studio emulator, this solved it for me!

 Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install C:\Users\aasmu\OneDrive\Proskjekt\Flutter_course\flash-chat-flutter\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl2080833837.tmp/base.apk (at Binary XML file line #28): co.appbrewery.flash_chat.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

1. Locate your androidManifest.xml

In the right corner of android studio where your project files are follow this path:

'your project name'/android/app/src/main/AndroidManifest.xml

Image showing file path in android studio with yellow highelighter

2. In the AndroidManifest.xml file, find this set of code:

<activity
   android:name=".MainActivity"
   android:launchMode="singleTop"
   android:theme="@style/LaunchTheme"        
   android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
   android:hardwareAccelerated="true"
   android:windowSoftInputMode="adjustResize">
   <intent-filter>
     <action android:name="android.intent.action.MAIN"/>
     <category android:name="android.intent.category.LAUNCHER"/>
   </intent-filter>
</activity>

Image showing the section between the two perpendicular red lines

3. Copy and paste this line somewhere between '<activity' and the next '>'.

android:exported="true" Image showing the line pasted in between the yellow'<activity' and '<'

Your problem should now be solved!


If your problem persists:

  • Make sure your flutter doctor checks out, i had mine checked out on everything except Visual studio when i solved this. (type 'flutter doctor' in the android studio terminal)
  • Check these two things mentioned in this answer. https://stackoverflow.com/a/56417433/14637333

Upvotes: 13

add this property to as from android 12 its required to be write this for activity and your device has android api level 31 which is android - 12

android:exported="true"

Upvotes: 0

Jashwanth Neela
Jashwanth Neela

Reputation: 463

Even I faced the same issue. I'm able to overcome it by adding below code for the particular service directly in the plugin.

android:exported="true"

You can find the plugin code in the below path

your_flutter_sdk_location/.pub-cache/hosted/pub.dartlang.org/package_name

Upvotes: 5

Harsh Mantri
Harsh Mantri

Reputation: 93

As per your question, your issue is arriving of FlutterFirebaseMessagingService. If you see in log there is already mention that

io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: Targeting S+ (version 31 and above)
requires that an explicit value for android:exported be defined when intent filters are present]

You just need to delete extra android:exported="false" from intent-filter. put here as like

            <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>

also update plugin, if they are not updated

  • firebase_core: ^1.16.0
  • firebase_messaging: ^11.3.0

Upvotes: 0

Related Questions