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


当前回答

对于你们所有人都有同样的问题,但当你合并清单时,没有任何错误,这个解决方案为我工作,没有编辑你的“清单”文件和改变任何配置,删除这个,删除那个等。

打开“设置”。gradle”文件。 添加代码“gradlePluginPortal()”。

如果你开始一个新项目,如果你使用更新的Android Studio,代码可能会自动出现,但你需要再添加一次,如下所示: pluginManagement { 存储库{ gradlePluginPortal () 谷歌() mavenCentral () jcenter () Maven {url 'https://jitpack.io'} }

并再次输入代码“gridlePluginCentral()”。

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven {url 'https://jitpack.io'}
        gradlePluginPortal()
    }
}

在我的案例中,这样的问题通常发生在我们使用github用户库并将其用于布局文件或作为java文件中的“导入”时。让你的Android Studio保持最新状态并保留旧版本总是一个好主意,因为通常会对配置、库和其他支持文件进行更改。最好避免使用来自github用户的库,最好使用来自谷歌的库。

其他回答

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

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

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

去refactor——>迁移到ANDROID X。

一定要备份你的项目。

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

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

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

这将修复错误:

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

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

我的解决方案是这样的:

1-开舱单

在右上方,检查突出显示的问题,如下所示:

3 .点击红色的问题图标。这将打开问题标签如下。

4-一个一个解决

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

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

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