首页 文章

Manifest Merger在Android Studio中出现多个错误失败

提问于
浏览
120

所以,我是Android和Java的初学者 . 我刚开始学习 . 我今天在试用Intent时遇到了错误 .

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

我在这里找到了一些解决方案并试图实现它们,但它没有用 .

这是我的build.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>

这是我编码的第一周,如果这是一件非常愚蠢的话,我很抱歉 . 我真的很陌生,没有找到任何其他地方要问 . 对不起,如果我违反任何规则

22 回答

  • 0

    minium sdk版本应该与你正在使用的modules / lib相同 . 例如:你的模块min sdk版本是26,你的app min sdk版本是21它应该是相同的 .

  • 0

    从mainfest文件中删除 <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

    Open application manifest(AndroidManifest.xml) ,click on Merged Manifest.Check image

    enter image description here

    你可以在右列中查看错误,尝试解决错误 . 它可能会帮助一个有同样问题的人 .

  • 423

    我也遇到了同样的问题,经过大量研究后发现了解决方案:

    你的min sdk版本应该与你正在使用的模块相同,例如:你的模块min sdk版本是14,你的app min sdk版本是9它应该是相同的 . 如果你的应用程序和模块的构建版本不一样 . 同样它应该相同简而言之,您的应用build.gradle文件和清单应该具有相同的配置没有像清单文件中两次添加相同权限的重复,相同的活动提到两次 . 如果您从项目中删除了任何活动,也可以从清单文件中删除它 . 有时它是因为清单文件的标签,图标等标签:a)在清单标签中添加xmlns:tools行 . b)在应用程序标记中添加工具:replace =或tools:ignore = .

    例:

    <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的cardview .support:cardview-v7:25.3.1和appcompat v7:26.0.0使用版本v7:26.0.0的cardview,因此两个库中存在distrpancy因此会出错

    错误:任务':app:processDebugManifest'的执行失败 .

    清单合并失败:来自[com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27的属性meta-data#android.support.VERSION@value value =(26.0.0-alpha1): 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

  • 36

    For me THIS works -

    AndroidManifest.xml 中查找合并错误

    enter image description here

    点击 AndroidManifest.xml 中的Merged Manifest

    enter image description here

    您可以在右列中查看清单合并错误 . 它可能有助于解决这个问题 .

  • 50

    我遇到了同样的问题,我刚刚在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">
    

    希望它会有所帮助 .

  • 0

    除了可用的解决方案,请同时检查 .
    如果您在 AndroidManifest.xml 中设置了 android:allowBackup="false" ,则其他依赖项中的 android:allowBackup="true" 可能存在冲突 .

    Solution
    根据@CLIFFORD P Y的建议,切换到 AndroidManifest.xml 中的 Merged Manifest . Android Studio会建议在 AndroidManifest.xml 中的 <application /> 中添加 tools:replace="android:allowBackup" .

  • 1

    在我的情况下,它显示错误,因为 <uses-permission> 元素中存在冗余 . 因此,请检查您的 AndroidManifest.xml 文件 .

    Android Studio version is 3.0.1

    Operating System is Windows 7

    这是截图供参考 .

    Screen-shot which shows redundancy in manifest file.

  • 0

    通常在清单中出现错误时发生 . 打开AndroidManifest.xml . 单击合并的清单选项卡 . 可以在那里看到错误 . 还包括那里提到的建议 . 当我在导入com.google.android.gms时出现类似问题时.maps.model.LatLng,它建议我在应用程序标记中包含工具:overrideLibrary =“com.google.android.gms.maps”,并且构建成功 .

  • 0

    我的情况我已经修好了

    build.gradle(模块:app)

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

    这个答案与OnSignal推送通知有关

  • 0

    在过去的几天里,我也遇到了同样的问题 . 但之后,经过大量的研究,我终于找到了解决方案 .
    为了解决这个问题,您需要做的是:
    1.检查项目的 build.gradle 文件和模块的 build.gradle 文件是否包含所有依赖项的相同版本 .
    2.确保,您的项目的 compileSdkVersionbuildToolsVersionminSdkVersiontargetSdkVersion 与您添加到项目中的 moduleslibraries 中的项目相匹配 .

    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.appname"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 22
        versionName "2.0.3"
    
    }
    

    希望这可以帮助 .

  • 9

    如果在添加 Android Library Module 之后又出现此错误 .
    您可以通过从 Android Library ModuleAndroidManifest.xml 中简单删除 android:label="@string/app_name" 来修复它

  • 1
    • AndroidManifest.xml

    • 在应用程序中,添加 tools:replace="android:icon, android:theme

    • 在Manifest根目录下,添加 xmlns:tools="http://schemas.android.com/tools

    • build.gradle

    • 从root用户添加 useOldManifestMerger true

  • 7

    打开你的gradle控制台,然后你看gradle建议你添加特定的行(如:tools:replace =“android:allowBackup”或tools:replace =“android:label”等) . 将该行添加到标记和同步gradle下的清单文件中,就是这样 .

  • 97

    只需在项目清单应用程序标记中添加以下代码即可...

    <application
            tools:node="replace">
    
  • 1

    在我的情况下,它发生在 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>
    
  • 1

    作为Android Studio的新手,就我而言,我已经将一个现有的项目从Eclipse迁移到了Android Studio,发现我的Manifest.xml中有一个活动的重复定义没有被Eclipse选中显示为Gradle错误 .

    我通过Gradle Console(屏幕右下角)找到了这个 .

  • 1

    当我折射(使用SHIFT F6重命名)我们的文件中的字段名称并且它要求你在任何地方更改它时我发生了两次,我们没有注意改变名称到处都是 . 例如,如果Java类中有变量名“id”,则使用SHIFT F6重命名它 . 如果您没有注意下一个对话框,它将询问您将改变ID的任何其他地方,并勾选检查所有它将从新值更改布局文件中的所有ID .

  • 0

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

    <activity android:name="com.futuretech.mpboardexam.Game" ></activity>
    
    //and launcher also------like that
    
    
    
    //solution:use only one
    
  • 6

    我正在使用 FirebaseUI LibraryFacebook SDK Library ,这导致了我的问题 .

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

    here,我摆脱了这个问题 .

    有了 FirebaseUI libraryFirebaseUI library ,以前版本的Facebook SDK也是它的一部分 .

    如果您使用的是 both 库,请 remove the Facebook SDK Library .

  • 11

    把它放在app模块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'
            }
        }
    }}
    

    from this

  • 3

    补充Phan Van Linh的答案 . 我删除了这些行:

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

相关问题