user2461391
user2461391

Reputation: 1433

How to change the minSdk version in Android Studio?

I am trying to get a basic hello world program running on my phone, however Android Studio keeps on reverting to minSDK level 20, when I specified 14. Here is the process I am using:

-Start Android Studio 0.8.2
-Select New Project
-Select Minimum SDK as API 14: Android 4.0
-Select Blank Activity
-The new project is now open. My android device, running 4.4.2 API 19 is plugged in.
-Select "Run app"
-The "Choose Device" dialog opens, shows my android device, but shows compatibility as No, minSdk(API 20, L preview)!= deviceSdk(API19)

The following is my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-L'
    buildToolsVersion "20.0.0"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Changing 'compileSdkVersion' to 14 results in an error, "failed to find target android-14".

Any ideas? Thanks!

Upvotes: 1

Views: 2687

Answers (2)

CommonsWare
CommonsWare

Reputation: 1006584

The "L" Developer Preview is a special snowflake that breaks all the normal rules for version management. :-(

Unless you are an experienced Android developer specifically testing on "L", change compileSdkVersion to something like 19 (note: may require you to download the SDK Platform for API Level 19 from the SDK Manager) and change targetSdkVersion to 19.

Changing 'compileSdkVersion' to 14 results in an error, "failed to find target android-14".

You need to download the API Level 14 "SDK Platform" in the SDK Manager.

Upvotes: 4

fvasquezjatar
fvasquezjatar

Reputation: 278

try this:

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"

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

If the target keep giving to you this problem try putting a lower version like CommonsWare said !

Upvotes: 1

Related Questions