Bill
Bill

Reputation: 393

Android Studio minSdkVersion not working

The minSdkVersion directive in my build.gradle appears not to be working (Android Studio 0.8.2)

Here's the build.gradle for the "mobile" module:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.android.gms:play-services-wearable:+'
}

When I try to debug it on my Samsung Galaxy S4 (API 19) I see this message in the "Compatible" column:

"No, minSdk(API 20) > deviceSdk(API 19)"

Minimum SDK should clearly be 9 as specified by the build.gradle. If I try to launch it anyway I get:

"Failure [INSTALL_FAILED_OLDER_SDK]"

I've scoured this project for any indication of something that could force the minSdk to 20. Nothing in AndroidManifest.xml. This project is a wearable app.

I've built another wearable app on the same machine and it loads and runs on the Samsung without a problem. This app that I'm trying to use was put together by a friend. It has only a small amount of code. The build.gradles are identical.

Totally baffled. Please help!

Upvotes: 6

Views: 7405

Answers (2)

papercut
papercut

Reputation: 59

Android L version (SDK 20) will be overrides minSdkVersion to 20. You should change your build version to 19 or below version of SDK. for example,

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
        applicationId "example.myapplication"
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                         'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:19.+'
}

Modify your build.gradle file like this, and resync your project and rebuild it. also you should install 19.1 sdk libraries to using SDK Managers. Run android studio as administrator will be help to solve another problems when you install sdk and rebuild your project.

Upvotes: 1

user3630796
user3630796

Reputation: 1

you can change compileSdkVersion 20 to compileSdkVersion 16 to have a try ,it works to me

Upvotes: 0

Related Questions