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


当前回答

发生此错误是因为在Manifest根目录下没有合适的语句,例如:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.test">

所以你应该删除其中的额外文本。

其他回答

删除<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文件显示歧义。

在我的情况下,我使用一些注释从jetbrains库。我删除了那些注释和依赖项,它工作得很好。

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

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

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

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

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

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

我通过删除AndroidManifest.xml中的下面一行来解决这个问题

android:allowBackup="true"

把这个放在你的应用模块build.gradle的末尾:

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '25.3.0'
        }
    }
}}

从这个