Flutter AndroidManifest 错误

Cha*_* Jr 6 android metadata android-manifest flutter

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

  • 出了什么问题:任务 ':app:processDebugManifest' 执行失败。

    清单合并失败:属性 meta-data#android.support.VERSION@value value=(25.4.0) from [com.android.support:appcompat-v7:25.4.0] AndroidManifest.xml:28:13-35 也是目前在 [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0)。建议:将 'tools:replace="android:value"' 添加到 AndroidManifest.xml:26:9-28:38 的元素以覆盖。

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

<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>
Run Code Online (Sandbox Code Playgroud)

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

hs7*_*7it 11

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

<application
    tools:replace="android:label"
    android:name="io.flutter.app.FlutterApplication"
    android:label="flutterwp" 
    android:icon="@mipmap/ic_launcher">
Run Code Online (Sandbox Code Playgroud)

并且不要忘记添加这样的工具:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wp"
xmlns:tools="http://schemas.android.com/tools">
Run Code Online (Sandbox Code Playgroud)