【问题标题】:Manifest Merger failed with multiple errors in Android Studio清单合并失败,Android Studio 中出现多个错误
【发布时间】:2016-06-20 22:57:58
【问题描述】:

所以,我是 Android 和 Java 的初学者。我刚开始学习。今天我在试验 Intent 时,遇到了一个错误。

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

我在这里找到了一些解决方案并尝试实施它们,但没有奏效。

这是我的 build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.example.rohan.petadoptionthing"
    minSdkVersion 10
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}

这是我的 AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>

package="com.example.rohan.petadoptionthing" >

<application

    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity android:name=".Second"
        />

    <activity android:name=".third"/>
    <activity android:name=".MainActivity"/>


</application>

这是我编码的第一周,如果这真的很愚蠢,我很抱歉。我对此真的很陌生,没有找到任何其他地方可以问。如果我违反了任何规则,请见谅

【问题讨论】:

  • 删除menifest.xml文件中的
  • 有关错误的详细信息,您可以查看Android Studio中右下角的Gradle Console。
  • 我希望这个link会有用。
  • 我遇到了同样的错误。但是通过在项目和库中保持相同的最小 SDK 来解决它。
  • youtu.be/K88WaSm3q8Y "Manifest Merger 失败,Android Studio 中出现多个错误"?

标签: android xml


【解决方案1】:

在我的例子中,我使用了 jetbrains 库中的一些注释。我删除了这些注释和依赖项,它运行良好。

所以请仔细检查android代码中的库和依赖项。

【讨论】:

    【解决方案2】:

    如果您在 build.gradle 文件中使用多个 manifestPlaceholder 项目,则必须将它们添加为数组元素,而不是单独的项目。

    例如这会导致构建错误或编译错误:“java.lang.RuntimeException: Manifest merge failed with multiple errors”:

    android {
        ...
        defaultConfig {
            manifestPlaceholders = [myKey1: "myValue1"]
            manifestPlaceholders = [myKey2: "myValue2"] // Error!
        }
    }
    

    这将修复错误:

    android {
        ...
        defaultConfig {
            manifestPlaceholders = [myKey1: "myValue1", myKey2: "myValue2"]
        }
    }
    

    【讨论】:

      【解决方案3】:

      这是因为您将新材料库与旧支持库一起使用。

      您必须将android.support 迁移到androidx 才能使用com.google.android.material

      如果您使用的是android studio v 3.2或更高版本,只需

      去重构 ---> 迁移到 ANDROID X。

      请备份您的项目。

      【讨论】:

        【解决方案4】:

        在看到 CLIFFORD 看到错误的答案后,帮助我解决这个问题的方法是将意图过滤器操作标记中的 'android:namex' 重命名为 'android:name'。如果相同的解决方案对其他人有帮助。

            <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:namex="android.intent.action.MAIN" />
        
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        

        【讨论】:

          【解决方案5】:

          我遇到了一个奇怪的问题。将变量 name 重命名为 user_name 时,我错误地将项目的所有名称重命名为 user_name。所以我的 xml 标签 &lt;color name:""&gt; 变成了 &lt;color user_name:""&gt; 字符串、样式和清单也是如此。但是当我检查合并的清单时,它什么也没显示,因为我只有一个清单,什么都找不到。

          所以,请检查您是否有任何格式错误的 xml 文件。

          【讨论】:

            【解决方案6】:

            就我而言,我的应用程序标签包括:

             <application
                android:name=".common.MyApplication"
                android:allowBackup="false"
                android:extractNativeLibs="false"
                android:icon="@mipmap/ic_launcher"
                android:label="@string/app_name"
                android:supportsRtl="true"
                android:theme="@style/AppTheme"
                android:usesCleartextTraffic="true"
                tools:ignore="GoogleAppIndexingWarning"
                tools:replace="android:appComponentFactory">
            

            我通过将新参数添加为 android:appComponentFactory=""

            解决了这个问题

            所以我的最终应用标签变成了:

            <application
                android:name=".common.MyApplication"
                android:allowBackup="false"
                android:extractNativeLibs="false"
                android:icon="@mipmap/ic_launcher"
                android:label="@string/app_name"
                android:supportsRtl="true"
                android:theme="@style/AppTheme"
                android:usesCleartextTraffic="true"
                tools:ignore="GoogleAppIndexingWarning"
                tools:replace="android:appComponentFactory"
                android:appComponentFactory="">
            

            当我厌倦了使用 firebase-auth 最新版本为“19.3.1”时,我遇到了上述问题。而在我的项目中,我已经在使用 firebase,但版本是“16.0.6”。

            【讨论】:

              【解决方案7】:

              我也遇到了这个错误。在构建日志中,最后一行是“无法编译值文件”。

              因此,如果您遇到同样的问题,那么只需在 gradle.properties 文件中添加以下行很可能会解决问题。

              android.enableJetifier=true
              

              我的意思是它为我修复了 Manifest Merger failed with multiple errors in Android Studio 错误。

              【讨论】:

                【解决方案8】:

                检查清单中是否声明了任何重复的活动。这是我的错误,删除重复项后问题解决了。

                【讨论】:

                  【解决方案9】:

                  简单的答案交叉检查:

                  您可能会在 manifest.xml 文件中多次定义 Same Activity。

                  您在 manifest.xml 文件中定义的活动或服务或接收者不在您的项目结构中。

                  【讨论】:

                  • 请不要将代码块用于非代码内容。您的答案不包含代码,因此不应缩进。
                  【解决方案10】:

                  我通过删除 android:replace 标签解决了这个问题

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 2021-11-24
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 2021-09-25
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多