Flutter AndroidManifest 错误

Flutter AndroidManifest Error

我刚刚将一个在早期版本的 Flutter 和 Android studio 中构建的项目移植到新机器上并更新了软件。尝试在模拟器中构建我的 Android 项目时,出现以下错误...

这就是我的清单的样子...

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.myfavkpopflutterexample"
 xmlns:tools="http://schemas.android.com/tools"
>

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />

<!-- The INTERNET permission is required for development. Specifically,
     flutter needs it to communicate with the running application
     to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases you can leave this as-is, but you if you want to provide
     additional functionality it is fine to subclass or reimplement
     FlutterApplication and put your custom class here. -->
<application android:name="io.flutter.app.FlutterApplication" android:label="myfavkpopflutter_example" android:icon="@mipmap/ic_launcher">
    <activity android:name=".MainActivity"
              android:launchMode="singleTop"
              android:theme="@android:style/Theme.Black.NoTitleBar"
              android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
              android:hardwareAccelerated="true"
              android:windowSoftInputMode="adjustResize">
        <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                tools:replace="android:value"
                android:value="true" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

我已经添加了建议的 tools:replace="android:value",但我仍然遇到同样的错误。我见过仅 Android Studio 的类似问题。我将其添加到 SO 中是因为我认为它可能与我的 Flutter 构建有关。

我也有这个问题,但我通过这个解决了。 转到项目 directory/build,然后您将看到 google_sign_in、image_picker、firebase 文件夹或任何已安装的依赖项。删除它们。返回 pubspec 文件,再次执行 Packages get 和 Packages upgrade。

问题可能出在 image_picker 文件夹,删除 image_picker 就足够了。如果这确实解决了您的问题,请查看 manifest-merger-debug-report.txt,您将了解原因。 希望您的问题得到解决。

我也遇到了同样的问题。 我通过应用错误消息中的建议解决了问题。 添加 tools:replace="android:label" 在 (\android\app\src\main\AndroidManifest.xml) 中添加 tools:replace="android:label" 像这样:

<application
    tools:replace="android:label"
    android:name="io.flutter.app.FlutterApplication"
    android:label="flutterwp" 
    android:icon="@mipmap/ic_launcher">

别忘了添加这样的工具:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wp"
xmlns:tools="http://schemas.android.com/tools">

我在尝试将 AWS Datastore 添加到我的 Flutter 项目时遇到了这个问题,该项目已经具有用于本地 OCR 的 Google MLKit。 Datastore 或 MLKit 都可以,但不能同时使用。

对我有用的:

将以下内容添加到 app\src\main\AndroidManifest。xml

tools:replace="android:name"

在 AndroidManifest 中使用以下声明 -

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ABC"
xmlns:tools="http://schemas.android.com/tools">