2

On a brand new install of the latest AndroidStudio running the New Project template with min SDK selection of 15 (ICS) trying to run on a Nexus 5 running API 19, I get the INSTALL_FAILED_OLDER_SDK error with the following output. I have made no changes to the project from what the template has generated, so this would be a clean first run that I would expect to work.

Waiting for device.
Target device: lge-nexus_5-{device id}
Uploading file
    local path: /home/{my user name}/AndroidStudioProjects/MyApplication/app/build/outputs/apk/app-debug.apk
    remote path: /data/local/tmp/com.example.{my user name}.myapplication
Installing com.example.{my user name}.myapplication
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.{my user name}.myapplication"
pkg: /data/local/tmp/com.example.{my user name}.myapplication
Failure [INSTALL_FAILED_OLDER_SDK]

This is the default build.gradle file generated for the app

apply plugin: 'com.android.application'

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

    defaultConfig {
        applicationId "com.example.{my user name}.myapplication"
        minSdkVersion 15
        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'])
}
Rich
  • 36,270
  • 31
  • 115
  • 154
  • are you sure about `targetSdkVersion 'L'`? shouldn't it be `targetSdkVersion 21`? – njzk2 Jun 27 '14 at 19:27
  • @njzk2 That's what AndroidStudio generated. I did notice that and try changing it to 20, and that didn't work either – Rich Jun 27 '14 at 19:30
  • did you also modify the compile version that has "android-L"? – blh83 Jun 27 '14 at 19:46
  • I believe this was discussed over here earlier today ; http://stackoverflow.com/questions/24457831/failure-install-failed-older-sdk-android-l – harism Jun 27 '14 at 19:53
  • See my answer at http://stackoverflow.com/questions/24465289/android-studio-failure-install-failed-older-sdk/24601830#24601830 – johnnie mac Jul 07 '14 at 01:13

1 Answers1

3

Check the doc at http://developer.android.com/preview/setup-sdk.html.

You have to use

minSdkVersion 'L'

and you have to run the app in device with Android-L or an emulator with Android-L. The build system when compileSdkVersion is 'android-L' or targetSdkVersion is 'L' forces the minSdk to 'L' to prevent apps published with the API in preview.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841