【问题标题】:How can solve Manifest merger failed with multiple errors?如何解决 Manifest 合并失败并出现多个错误?
【发布时间】:2018-03-09 17:31:40
【问题描述】:

我是 android 的初学者,在尝试构建项目时遇到此错误:

清单合并失败并出现多个错误,请参阅日志


阅读堆栈溢出的一些答案但无法解决我的问题,我的 gradle 是这样的:

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.behineh.seaapp"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


这是我的清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.behineh.seaapp">
      <application
        android:allowBackup="true"
        tools:replace="android:allowBackup"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="false"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait"></activity>
        <activity android:name=".LoginActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


我该如何解决问题?谢谢大家。
我的完整错误日志:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

【问题讨论】:

标签: android


【解决方案1】:

您的 APK 文件只能包含一个 AndroidManifest.xml 文件,但您的 Android Studio 项目可能包含多个——由主要源集、构建变体和导入的库提供。因此,在构建您的应用程序时,Gradle 构建会将所有清单文件合并到一个清单文件中

你可以像这样合并清单

<application
    tools:node="merge"
    tools:replace="android:label, android:icon, android:theme, 
    android:allowBackup">

</application>

查看 android 开发者文档了解更多详情

https://developer.android.com/studio/build/manifest-merge.html

【讨论】:

  • 但是包含自己的 android 清单的库将与您的清单合并。这里好像有问题
  • 如果你只有一个清单所以不需要工具:replace="android:allowBackup"
猜你喜欢
  • 1970-01-01
  • 2018-12-08
  • 1970-01-01
  • 1970-01-01
  • 2020-02-21
  • 2021-11-27
  • 2019-11-28
  • 2021-09-25
  • 1970-01-01
相关资源
最近更新 更多