Search code examples
android-studiogoogle-play-servicesandroid-manifestandroid-min-sdk

Android Studio - uses-sdk:minSdkVersion 7 cannot be smaller than version 9 declared in library


Until now I had android:minSdkVersion="7" in my app. Later I had to add google play services that require a minSdkVersion="9". And I got this error:

uses-sdk:minSdkVersion 7 cannot be smaller than version 9 declared in library
[com.google.android.gms:play-services:8.4.0] C:\AppsFolder\MyApp\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\8.4.0\AndroidManifest.xml

I didn't really mind setting a higher minSdk so I changed it to android:minSdkVersion="9"

But I still get the same error...I cleaned and rebuilt the project many times but this keeps happening. Somehow Android Studio still sees the android:minSdkVersion="7" somewhere. Any ideas how to fix this?

I'm using Android Studio 1.5.1


Solution

  • It seems that you are changing minSdkVersion directly in AndroidManifest.xml file. Android Studio uses gradle files for those settings and not manifest file.

    You should remove those entries from manifest and edit your application build.gradle file (located in your project root/app/ folder)

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "com.yourdomain.yourpackage"
            minSdkVersion 9
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
        }
    ...