Manifest Merging Failed: Android Studio

2020-03-30 06:00发布

问题:

I am not sure what's the issue. I googled and though it was about matching the sdk versions. They are the same as follows:

build.gradle

android {
compileSdkVersion 17
buildToolsVersion "19.0.1"

defaultConfig {
    minSdkVersion 4
    targetSdkVersion 17
}

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}
dependencies {
compile project(':slidingMenu')
compile project(':slidingMenu')
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
compile files('libs/Parse-1.4.0.jar')
}

Manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gurbani.ujagar"
android:hardwareAccelerated="true"
android:installLocation="preferExternal"
android:versionCode="26"
android:versionName="7.0" >

<uses-sdk
    android:minSdkVersion="4"
    android:targetSdkVersion="17" />

回答1:

You will be ended up with this error, If your libraries/modules uses different minSdkVersion or targetSdkVersion inside your project.

To find , In which module actual conflicts are happening you can see your Gradle Console output.

Best practice is to have minSdkVersion 8 at least because most of the libraries like play services etc using this.

Please do the following change and sync Project with gradle

Try to Use minsdkVesion 8 in all your build.gradle files as well as AndroidManifest.xml files ans sync.

If it doesn't solves the problem go through your gradle console to and make required changes as per the error shown.

Note : While compilation, your minSdkVersion and targetSdkVersion in AndroidManifest.xml will be overridden by what you have mention in your build.gradle files.



回答2:

I think slidingMenu library minSdkVersion is greater than yours (minSdkVersion 4). So manifests cant be merged. You cant use library that requires min version 11 (e.g.) in app that works on api version 4.