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


当前回答

发生在我身上两次,当我折射(重命名与SHIFT + F6)在我们的文件中的一个字段的名称,它要求你改变它到处,我们没有注意改变的名字到处。 例如,如果在Java类中有一个变量名为“id”,并使用SHIFT + F6重命名它。如果你不注意下一个对话框,它会问你它会在哪里改变id,你勾选所有,它会改变你布局文件中的所有id的新值。

其他回答

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

打开“设置”。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用户的库,最好使用来自谷歌的库。

在过去的几天里,我也经历了同样的问题。但经过大量研究,我终于找到了解决方案。 为了解决这个问题,你需要做的是: 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"

}

希望这有帮助。

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

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

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

这将修复错误:

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

在看到CLIFFORD的回答看到错误后,帮助我解决这个问题的是在intent-filter动作标签中将“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>

如果你的项目瞄准的是Android 12,那么 在所有<activity>标签中添加<intent-filter>

android:exported="true/false"