0

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!

Jishan
  • 1,654
  • 4
  • 28
  • 62
  • What is `minSdkVersion` in your `build.gradle` file? You need to change it to be at least 7 as the error message says. – Code-Apprentice Aug 17 '16 at 19:52
  • @Code-Apprentice actually I couldn't find the line! I have added the gradle file! – Jishan Aug 17 '16 at 20:03
  • Possible duplicate of [Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller](http://stackoverflow.com/questions/24718824/manifest-merger-failed-uses-sdkminsdkversion-8-cannot-be-smaller) – Code-Apprentice Aug 22 '16 at 16:45

1 Answers1

1

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
    }
    // ...
}
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • I am stupid, but I couldn't find the line! i have added my Gradle file in the question can you please point it out! Many thanks. – Jishan Aug 17 '16 at 20:00
  • @jeet No problem. It looks like your `build.gradle` file doesn't have it. Did you copy this file from somewhere or was it generated by some tool? It looks different than the `build.gradle` files which I am familiar with and which are generated by Android Studio when you start a new project. – Code-Apprentice Aug 17 '16 at 20:06
  • Thanks. I actually purchased this template from an website to kickstart my development, now it seems I have slowed down! – Jishan Aug 17 '16 at 20:13
  • @jeet I hope the template includes more than just this manifest file...and more than just a "Hello, World!" app. You can get that for free with Android Studio. – Code-Apprentice Aug 17 '16 at 23:23