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


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

作为Android Studio的新手,在我的情况下,我已经将一个现有的项目从Eclipse移动到Android Studio,并发现在我的Manifest.xml中有一个重复的活动定义,而Eclipse没有拾取它,这显示为一个Gradle错误。

我在Gradle控制台(屏幕右下角)找到了这一点。

打开应用程序清单(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="false",那么在其他依赖项中android:allowBackup="true"可能会有冲突。

解决方案 根据@CLIFFORD P Y的建议,切换到合并清单在你的AndroidManifest.xml。Android Studio将建议添加工具:replace=" Android:allowBackup"在<application />在你的AndroidManifest.xml。

我也遇到了同样的问题,我只是在我的manifest.xml中添加了一行,它为我工作了。

tools:replace="android:allowBackup,icon,theme,label,name"> 

将这一行添加到

<application
    android:name=".MyApplication"
    android:allowBackup="true"
    android:icon="@drawable/launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:screenOrientation="portrait"
    android:supportsRtl="true"
    android:theme="@style/AppThemecustom"
    tools:replace="android:allowBackup,icon,theme,label">

希望能有所帮助。

在AndroidManifest.xml: 在应用程序中,添加工具:replace="android:icon, android:theme和 在清单根目录下,添加xmlns:tools="http://schemas.android.com/tools 在build.gradle: 在根节点添加useOldManifestMerger true

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

}

希望这有帮助。

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

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

通常发生在你的清单有错误的时候。打开AndroidManifest.xml。单击合并的清单选项卡。错误可以在那里看到。也包括那里提到的建议。当我在导入com.google.android.gms.maps.model. latlng时遇到了类似的问题,它建议我加入一些工具:overrideLibrary="com.google.android.gms. gms "。应用程序标签中的“Maps”,构建成功。

这是非常简单的错误,只有当你在mainifest.xml文件中定义任何活动调用两次时才会发生

<activity android:name="com.futuretech.mpboardexam.Game" ></activity>

//and launcher also------like that



//solution:use only one 

我使用了FirebaseUI库和Facebook SDK库,这导致了我的问题。

implementation 'com.firebaseui:firebase-ui-database:0.4.4'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

从[这里][1],我摆脱了这个问题。

随着FirebaseUI库的最新更新,之前版本的Facebook SDK也是其中的一部分。

如果你正在使用这两个库,请删除Facebook SDK库。

https://github.com/firebase/FirebaseUI-Android/issues/230

更新

从Android Studio 3.0及后续版本开始,app.gradle文件需要使用implementation或api而不是compile来添加应用程序的依赖项。

打开你的gradle控制台,然后你会看到gradle建议你添加特定的行(如:tools:replace="android:allowBackup"或tools:replace="android:label"等)。将这一行添加到您的清单文件下的标签和同步gradle,就是这样。

我的案子已经解决了

build.gradle(模块:应用)

defaultConfig {
----------
multiDexEnabled true
}
dependencies {
    ...........
    implementation 'com.google.android.gms:play-services-gcm:11.0.2'
    implementation 'com.onesignal:OneSignal:3.+@aar'
    }

这个答案转到OnSignal推送通知

在我的例子中,它显示了一个错误,因为<uses-permission>元素中有冗余。 因此,请在AndroidManifest.xml文件中检查相同的内容。

Android Studio版本为3.0.1

操作系统为Windows 7

这里是截图供参考。

把这个放在你的应用模块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'
        }
    }
}}

从这个

潘文林补充回答。我删除了这几行:

  android:icon="@mipmap/ic_launcher"
  android:label="name"

对我来说,这是可行的

在AndroidManifest.xml中查找合并错误

在AndroidManifest.xml中单击合并清单

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

最小sdk版本应该与您正在使用的模块/lib相同 例如:你的模块的最小sdk版本是26,你的应用程序的最小sdk版本是21。

只需在您的项目清单应用程序标签中添加以下代码…

<application
        tools:node="replace">

在我的例子中,它发生在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> 

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

android:allowBackup="true"

如上所示,只需迁移到Androidx,然后将最小sdk版本设置为26…毫无疑问,这是完美的

下面的黑客工作:

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

我通过删除android:replace标签解决了这个问题

我用Refactor ->迁移到AndroidX解决了这个问题

GL

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

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

如果在构建中使用多个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。

一定要备份你的项目。

简单答案交叉检查:

您可能在manifest.xml文件中多次被定义为Same Activity。

OR

您在manifest.xml文件中定义的活动或服务或接收器不在您的项目结构中。

在看到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>

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

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

在我的情况下,我的应用程序标签包括:

 <application
    android:name=".common.MyApplication"
    android:allowBackup="false"
    android:extractNativeLibs="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:ignore="GoogleAppIndexingWarning"
    tools:replace="android:appComponentFactory">

我解决了这个问题,我添加了新的参数作为android:appComponentFactory=""

所以我最后的应用标签变成:

<application
    android:name=".common.MyApplication"
    android:allowBackup="false"
    android:extractNativeLibs="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:ignore="GoogleAppIndexingWarning"
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="">

我在使用firebase-auth最新版本为“19.3.1”时遇到了上述问题。而在我的项目中,我已经在使用firebase,但版本是“16.0.6”。

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

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

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

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

android:exported="true/false"

在我的案例中,我通过在构建中更新类路径来解决这个问题。gradle(项目)文件到最新版本。

是这样的:

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
}

更新到最新版本后:

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.4'
}

一切都很正常!如果以上所有答案都不能解决问题,希望这能帮助到一些人。

我看到了答案,它们是完整的和有用的。无论如何,如果你正在完成Jetpack撰写测试代码实验室,并且在2021年底发现了这个错误,解决方案不是可接受的答案,你需要将目标sdk版本降低到30。

在app /构建。gradle,替换:

targetSdkVersion 31

:

targetSdkVersion 30

并再次运行Android测试

我也面临着这个错误。在构建日志中,最后一行是“编译值文件失败”。

因此,如果你面临同样的问题,那么只需在gradle中添加下面的行。属性文件很可能会修复这个问题。

android.enableJetifier=true

我的意思是它修复了Manifest合并失败的Android Studio错误。

检查清单中是否声明了任何重复的活动。这是我的错误,这个错误和问题解决后,删除副本。

我的解决方案是这样的:

1-开舱单

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

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

4-一个一个解决

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

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

在我的情况下,我在清单文件的元数据标签中使用firebase vision Dependencies上的多个模型,所以我将它们混合在一个值参数中,它确实解决了我的问题。以下是如何做到的:

<meta-data
    android:name="com.google.mlkit.vision.DEPENDENCIES"
    android:value="ocr,langid"/>