Flutter:firebasemessaging.FlutterFirebaseMessagingService:定位 S+(版本 31 及更高版本)需要显式值

Abi*_*san 1 migration android-manifest flutter android-12

我想运行一个现有的项目。它完全在 Android 12 下运行,但是当我要运行 Android 12 版本的三星手机时。然后我收到此类错误。

\n

错误 :

\n
\xe2\x9c\x93  Built build/app/outputs/flutter-apk/app-release.apk (104.1MB).\nInstalling build/app/outputs/flutter-apk/app.apk...                 3.3s\nError: ADB exited with exit code 1\nPerforming Streamed Install\n\nadb: failed to install /Users/abir/Documents/Office\nWork/appName-App-Old-Version/build/app/outputs/flutter-apk/app.apk: Failure\n[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI:\n/data/app/vmdl2043233695.tmp/base.apk (at Binary XML file line #124):\nio.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService: Targeting S+\n(version 31 and above) requires that an explicit value for android:exported be\ndefined when intent filters are present]\nError running application on SM G781B.\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的AndroidManifest.xml文件:

\n
<manifest xmlns:android="http://schemas.android.com/apk/res/android"\n    package="care.appname.health">\n    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>\n    <uses-permission android:name="android.permission.INTERNET" />\n    <uses-permission android:name="android.permission.RECORD_AUDIO" />\n    <uses-permission android:name="android.permission.CAMERA" />\n    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />\n    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\n    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>\n    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>\n\n    <!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->\n    <uses-permission android:name="android.permission.BLUETOOTH" />\n\n    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>\n    <uses-permission android:name="android.permission.VIBRATE" />\n\n    <uses-permission android:name="android.permission.INTERNET" />\n    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\n    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />\n   <application\n        android:label="appname"\n        android:name="${applicationName}"\n        android:icon="@mipmap/ic_launcher">\n        <activity\n            android:name=".MainActivity"\n            android:exported="true"\n            android:launchMode="singleTop"\n            android:theme="@style/LaunchTheme"\n            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"\n            android:hardwareAccelerated="true"\n            android:windowSoftInputMode="adjustResize">\n            <!-- Specifies an Android theme to apply to this Activity as soon as\n                 the Android process has started. This theme is visible to the user\n                 while the Flutter UI initializes. After that, this theme continues\n                 to determine the Window background behind the Flutter UI. -->\n            <meta-data\n              android:name="io.flutter.embedding.android.NormalTheme"\n              android:resource="@style/NormalTheme"\n              />\n            <intent-filter>\n                <action android:name="android.intent.action.MAIN"/>\n                <category android:name="android.intent.category.LAUNCHER"/>\n            </intent-filter>\n            <intent-filter>\n                <action android:name="FLUTTER_NOTIFICATION_CLICK" />\n                <category android:name="android.intent.category.DEFAULT" />\n            </intent-filter>\n        </activity>\n        <!-- Don't delete the meta-data below.\n             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->\n        <meta-data\n            android:name="flutterEmbedding"\n            android:value="2" />\n       \n    </application>\n</manifest>\n
Run Code Online (Sandbox Code Playgroud)\n

android:exported="true"也尝试了真假。但没有任何作用。我该如何解决这个问题?

\n

MKR*_* KH 5

将服务添加到应用程序,这对我有用。

<service android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService" android:exported="true"/>
Run Code Online (Sandbox Code Playgroud)