所以,我是一个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


当前回答

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

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

其他回答

如果在你添加了Android库模块之后,你会得到这个错误。 你可以通过简单地从android库模块的AndroidManifest.xml中删除android:label="@string/app_name"来修复它

我在这个问题上遇到了一个奇怪的遭遇。当重命名变量名称为user_name时,我错误地将所有名称重命名为项目的user_name。所以我的xml标签<color name:"">变成<color user_name:"">同样适用于字符串,样式,清单。但是当我检查合并的清单时,它什么也没有显示,因为我只有一个清单,没有什么要找的。

因此,检查是否有任何格式错误的xml文件。

打开应用程序清单(AndroidManifest.xml),单击编辑窗格底部的合并清单选项卡。查看下图:

从图像中您可以看到错误在右列,尝试解决错误。它可以帮助那些有同样问题的人。点击这里阅读更多。

此外,一旦你发现了错误,如果你从你正在使用的外部库中得到错误,你必须让编译器忽略外部库中的属性。 //在manifest中的application标签中添加此属性

   tools:replace="android:allowBackup" 
                                                                                                                                          
   //Add this in the manifest tag at the top

   xmlns:tools="http://schemas.android.com/tools"

在我的例子中,它发生在Activity标记中留下一些空的intent-filter

    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">

            <intent-filter>

            </intent-filter>

    </activity> 

所以去掉它们就解决了问题。

    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
    </activity> 

下面的黑客工作:

中添加xmlns:tools="http://schemas.android.com/tools"行 清单标签 添加 工具:取代= " android:图标,android:主题,android: allowBackup,标签,名称” 在应用程序标签中