firebase Flutter:安装_解析_失败_清单_畸形:installPackageLI期间解析失败

ztyzrc3y  于 2022-12-14  发布在  Flutter
关注(0)|答案(5)|浏览(234)

我的flutter应用程序没有安装在Android 12版本上。我尝试使用android:exported,但没有任何效果。它显示了这种类型的错误-

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

这是我的AndroidManifest.xml文件

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

我错过了什么?

5vf7fwbs

5vf7fwbs1#

如果你在android studio模拟器上运行flutter应用程序时收到此错误消息,这为我解决了问题!

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.找到您的androidManifest.xml文件

在您的项目文件所在的android studio的右角,请遵循以下路径:
“您的项目名称”
Image showing file path in android studio with yellow highelighter

2.在AndroidManifest.xml文件中,找到以下代码集:

<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.将此行复制并粘贴到“〈activity”和下一个"〉“之间的某个位置。

安卓系统:导出=“true”Image showing the line pasted in between the yellow'<activity' and '<'
你的问题现在应该解决了!

如果问题仍然存在:

  • 确保你的flutter医生检查出来,我有我的检查出来的一切,除了Visual Studio当我解决这个问题.(键入'flutter医生'在android工作室终端)
  • 检查此答案中提到的这两件事。https://stackoverflow.com/a/56417433/14637333
z5btuh9x

z5btuh9x2#

甚至我也面临着同样的问题。我能够通过直接在插件中添加特定服务的以下代码来克服它。

android:exported="true"

您可以在以下路径中找到插件代码

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

h79rfbju3#

根据您的问题,您的问题已经到达FlutterFirebaseMessagingService。如果您在日志中看到已经提到

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]

你只需要从intent-filter中删除多余的android:exported=“false”。

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

如果插件没有更新,也更新它们

  • firebase_core:^1.16.0年版
  • 防火墙消息:^11.3.0版本
vwoqyblh

vwoqyblh4#

从Android 12开始,将此属性添加到需要为活动编写此属性,并且您的设备具有Android API级别31,即Android - 12

android:exported="true"
tp5buhyn

tp5buhyn5#

很简单添加这行代码android:exported="true" AndroidManifest.xml
安卓系统/app/src/main/安卓系统清单. xml x1c 0d1x

相关问题