所以,我是一个Android和Java的初学者。我才刚刚开始学习。当我今天用Intent做实验时,我犯了一个错误。

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

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

这是我的身材。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> This is my first week with coding, I am sorry if this is a really silly thing. I am really new to this and did not find any other place to ask. Sorry if I broke any rules


当前回答

对我来说,这是可行的

在AndroidManifest.xml中查找合并错误

在AndroidManifest.xml中单击合并清单

您可以在右侧栏查看清单合并错误。这可能有助于解决这个问题。

其他回答

删除<activity android:name="。MainActivity"/>。正如你已经定义的那样:

 <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>

Manifest文件显示歧义。

我也面临着同样的问题,经过大量研究,我找到了解决方案:

Your min sdk version should be same as of the modules you are using eg: your module min sdk version is 14 and your app min sdk version is 9 It should be same. If build version of your app and modules not same. Again it should same ** In short, your app build.gradle file and manifest should have same configurations** There's no duplicacy like same permissions added in manifest file twice, same activity mention twice. If you have delete any activity from your project, delete it from your manifest file as well. Sometimes its because of label, icon etc tag of manifest file: a) Add the xmlns:tools line in the manifest tag. b) Add tools:replace= or tools:ignore= in the application tag.

例子:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.slinfy.ikharelimiteduk"
    xmlns:tools="http://schemas.android.com/tools"
    android:versionCode="1"
    android:versionName="1.0" >

  <application
      tools:replace="icon, label"
      android:label="myApp"
      android:name="com.example.MyApplication"
      android:allowBackup="true"
      android:hardwareAccelerated="false"
      android:icon="@drawable/ic_launcher"
      android:theme="@style/Theme.AppCompat" >
  </application>

</manifest>

如果两个依赖项的版本不同 示例:你正在使用appcompat v7 . 26.0.0和facebook com.facebook.android:facebook-android-sdk:[4,5) facebook使用com.android.support:cardview-v7 . 25.3.1版本的cardview, appcompat v7 . 26.0.0使用v7 . 26.0.0版本的cardview,因此在两个库中存在差异,因此会给出错误

错误:执行失败的任务':app:processDebugManifest'。

清单合并失败:属性元数据#android.support。VERSION@value value=(26.0.0-alpha1) from [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 [com.android.support:cardview-v7 . 25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1) 建议:在AndroidManifest.xml:25:5-27:41的元素中添加“tools:replace="android:value"”来覆盖。

因此,通过使用25.3.1版本的appcompat,我们可以避免这个错误

通过考虑以上几点,你将摆脱这个恼人的问题。 你也可以看看我的博客 https://wordpress.com/post/dhingrakimmi.wordpress.com/23

如果在构建中使用多个manifest占位符项。在Gradle文件中,必须将它们作为数组元素添加,而不是单独的项。

例如,这将导致一个构建错误或编译错误:RuntimeException:合并失败,出现多个错误。

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

这将修复错误:

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

这是因为您正在使用新的材料库和遗留的支持库。

你必须迁移android。为了使用com.google.android.material,支持androidx。

如果你使用的是android studio v 3.2或更高版本,简单

去refactor——>迁移到ANDROID X。

一定要备份你的项目。

在过去的几天里,我也经历了同样的问题。但经过大量研究,我终于找到了解决方案。 为了解决这个问题,你需要做的是: 1. 检查项目的构建。Gradle文件和模块的构建。Gradle文件包含所有依赖项的相同版本。 2. 确保项目的compileSdkVersion、buildToolsVersion、minSdkVersion和targetSdkVersion与您添加到项目中的模块或库中的版本相匹配。

compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
    applicationId "com.example.appname"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 22
    versionName "2.0.3"

}

希望这有帮助。