Jishan
Jishan

Reputation: 1684

Manifest Merger Fails

So recenlty I have been getting this error out of one of my projects:

Error:Execution failed for task ':ListViewAnimations-core-slh:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 7 declared in library [android - AS:StickyListHeaders:unspecified] D:\Android\MDS\UPLOAD\android - AS\ListViewAnimations-core-slh\build\intermediates\exploded-aar\android - AS\StickyListHeaders\unspecified\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="se.emilsjolander.stickylistheaders" to force usage

Here is the Manifest file for the same:

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

    <application android:allowBackup="true">
    </application>

</manifest>

And here is the Gradle file:

apply plugin: 'android-library'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':ListViewAnimations-core')
    compile project(':StickyListHeaders')
}

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

Why is this happening? What did I miss? Thanks a lot!

Upvotes: 0

Views: 216

Answers (1)

Code-Apprentice
Code-Apprentice

Reputation: 83517

This error message is perhaps a little misleading if you don't know how Android Studio creates a manifest file for your Android app. In this situation, it is important to understand that there are many variables set in app/build.gradle which are used while generating the manifest file. Specifically, the error message references the minSdkVersion value. You should open app/build.gradle and find the line with this variable. Then change its value to 7 or greater. In fact, many current apps use a value of at least 16.

Modify build.gradle as follows:

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig { 
        minSdkVersion 7 // This can be any number greater than 7
    }
    // ...
}

Upvotes: 1

Related Questions