55

Today I have downloaded Android Studio v 0.8.0 beta. I am trying to test my app on SDK 17 . Android studio error Failure [INSTALL_FAILED_OLDER_SDK] Here is my android manifest

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.vahe_muradyan.notes" >
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Main_Activity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

It seems that android studio uses configurations in build.gradle.Here is build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 'L'
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.vahe_muradyan.notes"
        minSdkVersion 8
        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'])
    compile 'com.android.support:appcompat-v7:19.+'
}
Vahe Muradyan
  • 1,115
  • 1
  • 11
  • 22

24 Answers24

27

There are my config to support L and old versions of android:

apply plugin: 'com.android.application'

android {
    buildToolsVersion "20.0.0"

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


    productFlavors {
        l {
            minSdkVersion 'android-L'
            targetSdkVersion 'android-L'
            compileSdkVersion 'android-L'
        }
        old {
            minSdkVersion 10
            targetSdkVersion 20
            //TODO comment second line if build is not compiles for "L"
            compileSdkVersion 20
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    lCompile 'com.android.support:appcompat-v7:21.+'
    oldCompile 'com.android.support:appcompat-v7:19.1.0'
}

As result you will have flavors:

oldDebug
oldRelease
lDebug
lRelease

And can install your application on old versions of android.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Vova K.
  • 678
  • 6
  • 19
  • Thanks for providing this :) – animaonline Jun 30 '14 at 20:43
  • Hmm...for me, this new info just confuses ME even more. I haven't yet even digested what 'Android-L' is. And maybe EVENTUALLY I might want to have various 'product flavors', but right now, I just want to get one or any set of values to load into my Nexus-7, running v4.4.4. My thought was that Google is now discouraging continuing to use the older '' info in the Manifest, because when I put it there, when using Android-Studio 0.8.1, it flashes on the screen that it intends to IGNORE that info, because presumably, it's getting somewhere else now. – David Jul 01 '14 at 23:58
  • 3
    Is this meant for mobile/build.gradle or wear/build.gradle? Neither seems to work as the IDE complains "cannot resolve symbol 'compileSdkVersion'" – Erik B Jul 02 '14 at 20:56
  • This is for mobile/build.gradle. Wear is the another project and you can compile his with any other sdk. – Vova K. Jul 03 '14 at 05:07
  • 1
    Its giving an error cannot resolve symbol 'compileSdkVersion' in product flavors. – Ravi Jul 03 '14 at 07:37
  • what is file name to write this ? – kort.es Aug 01 '14 at 12:15
  • How did you solve conflicts with `android:Theme.Material.Light` theme when building the old flavor? – DiogoNeves Aug 13 '14 at 15:15
  • Are you sure it is possible to compile with a different version per flavor? – gian1200 Aug 16 '14 at 18:42
  • I could not do it. During build with flavor gradle takes compile sdk from the first flavor. – Vova K. Aug 17 '14 at 07:30
  • Is this going to be necessary with the production version of L or is it just a workaround for the preview? – C. Ross Oct 03 '14 at 19:56
12

Do those changes in build.gradle file in the wear module

compileSdkVersion 20
targetSdkVersion 20

So the final wear/build.gradle content will be:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "your package name"
        minSdkVersion 20
        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'])
    compile 'com.google.android.support:wearable:+'
    compile 'com.google.android.gms:play-services-wearable:+'
}
Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
HocineHamdi
  • 191
  • 6
  • Thanks, I had similar issues. Seems that changing the 'L' to 20 in this mysterious build.gradle file solves the issue. Never thought I'd say this, but I find myself missing Eclipse... – JDS Jul 14 '14 at 16:10
  • What is the difference between sdk 20 and 'android-L'? – IgorGanapolsky Jul 23 '14 at 23:59
  • You can find in the Build.VERSION_CODES following: public static final int KITKAT = 19; public static final int KITKAT_WATCH = 20; public static final int L = 10000; – Vova K. Aug 17 '14 at 07:32
6

I'm using Android Studio Beta version 0.8.1 and I have the same problem. I now I sold my problem by changing the AVD (I'm using Genymotion) to API 19. and here is my build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.daroath.actionbar"
        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'])
}

enter image description here

Hope this help!

Daroath
  • 382
  • 3
  • 16
  • when you say changing the avd, do you mean the version in the android manifest file? you edited it in a text editor? what was it before? – barlop Aug 27 '14 at 08:25
  • no, in android studio the way you change "android sdk" is no more in manifest file, but u change it in "gradle.build" file instead.As my experience of the error is that when I set my gradle.build file like defaultConfig { applicationId "com.example.daroath.actionbar" minSdkVersion 14 targetSdkVersion 19 versionCode 1 versionName "1.0" } I need to choose an AVD with API19 or higher to run it. – Daroath Aug 28 '14 at 01:13
4

I ran into the same issue and solved it by downloading api level 20 using sdk manager and changing every string that points to android-L. I did it because I dont have a kitkat device and don't want to use emulator. See the image download the marked one.

Here's my build config:

apply plugin: 'com.android.application'

android {
compileSdkVersion 20//changed this from default
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.example.subash.test"
    minSdkVersion 12//changed this from default
    targetSdkVersion 20//changed this from default
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
  • Do you can use Material theme with these config? – Vova K. Jul 02 '14 at 10:37
  • for that you will need either emulator or device with material theme – Illegal Argument Jul 02 '14 at 10:53
  • Aha! Now I see (said the blind man)! So, now no matter what value I put into that new layout, for 'targetSdkVersion', Android Studio pops up an error, asking me to first INSTALL that version of the SDK, and to then re-sync the project. SO: The problem is that, even tho my SDK-manager says that all these various SDKs are installed (they always were), that suddenly this new Android-Studio must be looking in a diff place, to be able to find them. (I don't know the fix yet. Removing all my SDKs from 10 to 20 is NOT recommended, so I'll sit quietly til someone else discovers the needed-tweak.) – David Jul 02 '14 at 14:31
  • @Dave could you explain your problem exactly? the targetsdkversion and the compilesdk version both need to change(no need to specify app version in manifest in AS) according to what you have. I didnot have a android 4.4L device so I changed it. The above works for me so it should work for you too – Illegal Argument Jul 02 '14 at 14:37
  • Sorry...so today, I followed your recipe, and got rid of my 'Android-L' crap, and went back to putting numbered sdk-values in. Which is causing a different problem, in that now the builds no longer work...it says it can't find any of my earlier-installed numerical sdks. So, I'm thinking it can ONLY find that newly added Android-L sdk, so when I ask for anything older, I get this other problem. (Sigh.) – David Jul 02 '14 at 18:30
  • Ok, (re)started fresh, by completely removing Android-Studio install, then installed full 0.8.0 kit, and let it upgrade to 0.8.1. On both an existing (previous proj from 0.6.x) and on a new proj in 0.8.1, I use the generated build.gradle file as is, and get INDICATIONS of a clean build on each project. But, the kicker is: when I 'cd' to top of either proj-directory-tree, and search for '*.apk', I find no generated APK file! Conclusion: Google's 0.8.x kits for Android Studio are NOT YET READY FOR PRIME-TIME. This is on Win-7 64-bit, using search cmd 'dir /s *.apk' – David Jul 03 '14 at 22:33
  • Hmmm...see the bullet "Automatic platform component downloading during Gradle sync when a required platform is missing", at the webpage [ http://tools.android.com/recent/androidstudiobetareleased ]. I WAS seeing that prompt, when I alter the config to quit using 'android-L' and 'L', and tell it to use a numbered sdk, such as 19 or 18, etc. NOW I'm thinking that starting in 0.8.0, they are needing to COPY the specified SDK from its installed area (external to Android-Studio) into Android-Studio's installed-directory-tree. If so, there seems to be a glitch/bug...that dialog won't work for me. – David Jul 04 '14 at 01:07
  • At any rate, I'm declaring my canary (i.e. 0.8.1) DEAD! Translation: If we want to get any real dev-work done, we need to drop back to 0.6.x of Android-Studio, or use Eclipse, etc. Enough said? As always, tho, YMMV – David Jul 04 '14 at 01:13
2

As mentioned before switching to build 19 is the suggested route here until v20 is "fixed". This thread helped me solve the issue, but it seems similar answers have been posted here as well. https://code.google.com/p/android/issues/detail?id=72840

ThorinOakenshield
  • 161
  • 1
  • 2
  • 9
  • 2nd this. I removed v20 and L of build tools and android image and replaced with 19.1 build tools and Level 19. Then I removed the project and recreated it and now I can run my programs. – wmac Jul 27 '14 at 15:20
2

Change file AndroidManifest.xml

<uses-sdk android:minSdkVersion="19"/>
<uses-sdk android:minSdkVersion="14"/>
MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
2
<uses-sdk android:minSdkVersion="19"/>

In AndroidManifest.xml worked for me on Android Studio(Beta)0.8.2.

VMAtm
  • 27,943
  • 17
  • 79
  • 125
Kris Utter
  • 129
  • 2
  • 5
2

Failure [INSTALL_FAILED_OLDER_SDK]

basically means that the installation has failed due to the target location (AVD/Device) having an older SDK version than the targetSdkVersion specified in your app.

FROM

apply plugin: 'com.android.application'

android {

compileSdkVersion 'L' //Avoid String change to 20 without quotes
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.vahe_muradyan.notes"
    minSdkVersion 8
    targetSdkVersion 'L' //Set your correct Target which is 17 for Android 4.2.2
    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:appcompat-v7:19.+' // Avoid Generalization 
// can lead to dependencies issues remove +

}

TO

apply plugin: 'com.android.application'

android {
compileSdkVersion 20 
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.vahe_muradyan.notes"
    minSdkVersion 8
    targetSdkVersion 17
    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:appcompat-v7:19.0.0'
}

This is common error from eclipse to now Android Studio 0.8-.8.6

Things to avoid in Android Studio (As for now)

  • Avoid Strings instead set API level/Number
  • Avoid generalizing dependencies + be specific
Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
alkathirikhalid
  • 887
  • 12
  • 18
2

in the AndroidManifest.xml file change the user-sdk to older version <uses-sdk android:minSdkVersion="19"/>

youssef
  • 91
  • 1
  • 7
2

After a lot of research i found the solution for this huge error which i was struggling for 2 days.

Instead of changing the minSdkVerison & targetSdkVersion in build.gradle

Just open the Manifest file and use this

&ltuses-sdk 
android:minSdkVersion="17" 
android:targetSdkVersion="21"/

Goutham
  • 51
  • 5
1

The real issue is that with vanilla Android Studio v 0.8 beta, it only installs/recognize SDK 20 which is android L. In order to target another complieSDK you need to install it via the SDK manager. Once it is set, you can then change the compileSDK to a lower version and it should work.

you may also want to restrict the compatibility library, it needs to be restricted from using the latest version of the library so change the dependecy to something like :

compile('com.android.support:appcompat-v7:19.1.0') {
    // really use 19.1.0 even if something else resolves higher
    force = true
}
Ajibola
  • 1,218
  • 16
  • 28
1

I fixed this problem. I just modified the compileSdk Version from android_L to 19 to target my nexus 4.4.4.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'
    }
}
apply plugin: 'com.android.application'

repositories {
    jcenter()
}

android {
    **compileSdkVersion 'android-L'** modified to 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.antwei.uiframework.ui"
        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'])
    **compile 'com.android.support:support-v4:21.+'** modified to compile 'com.android.support:support-v4:20.0.0'
}

how to modified the value by ide.

select file->Project Structure -> Facets -> android-gradle and then modified the compile Sdk Version from android_L to 19

sorry I don't have enough reputation to add pictures

Ant小波
  • 57
  • 4
1

I initially went into the SDK Manager and updated all that it had set to update.

I also added in the SDK version for the version of Android I had on the Droid I had...Version 2.3.4(10)

I don't think that really fixed anything, and after a Android Studio restart as recommended after the SDK installs, I changed the minSdkVersion to 8 in the build.gradle file

I was then able to download the application to my Droid.

defaultConfig {
    applicationId "com.cmcjr.chuck.droid_u"
    minSdkVersion 8
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}

This is Android Studio installed on Ubuntu 12.04

Chulk Ches
  • 11
  • 1
1

Just go to build.gradle(Module:App) and change the minSdkVersion to whatever you are using with emulator.

Example:

defaultConfig {
        applicationId "com.example.raghu.sample"
        // Change the version in following line
        minSdkVersion 10 // <-- Whatever you are using with Emulator
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
offby1
  • 6,767
  • 30
  • 45
Raghu.k
  • 11
  • 1
0

Just installed Android Studio v 0.8.1 beta and ran into the same problem targeting SDK 19.

Copied 19 from the adt-bundle to android-studio, changed build.gradle to:

compileSdkVersion 19 targetSdkVersion 19

then project -> app -> open module settings (aka project structure): change compile sdk version to 19.

Now works fine.

johnnie mac
  • 126
  • 1
  • 7
0

Similar to a few posts prior - I went to SDK Manager and uninstalled v20 and version L. Then I installed version 19 and this problem was resolved and I could debug using my android device, no errors.

0

Another way to support Android L is to use custom lpreview property for Gradle. For instance:

lpreview = hasProperty('lpreview')

apply plugin: 'com.android.application'

android {
    compileSdkVersion lpreview ? "android-L" : 19
    buildToolsVersion "20.0.0"

    productFlavors { lpreview ? lpreview{} : classic{} }

    defaultConfig lpreview ? {} : {
        minSdkVersion 14
        targetSdkVersion 19
    }

Now, you can build your app with:

./gradlew clean
./gradlew -Plpreview assembleDebug

or

./gradlew -Plpreview installLpreviewDebug

This way you can build your app with lpreview property for Android L and without it for previous versions.

yyunikov
  • 5,719
  • 2
  • 43
  • 78
0

Try changing you sdk min version

<uses-sdk
    android:minSdkVersion="4"
    android:targetSdkVersion="19" />
MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
Guilherme Simão Couto
  • 1,016
  • 2
  • 12
  • 24
0

Check the 'minSdkVersion' in your build.gradle

The default project creates it with the latest API, so if you're phone is not yet up-dated (e.g. minSdkVersion 21), which is probably your case.

Make sure the minSdkVersion value matches with the device API version or if the device has a higher one.

Example:

defaultConfig {
    applicationId 'xxxxxx'
    minSdkVersion 16
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
Alécio Carvalho
  • 13,481
  • 5
  • 68
  • 74
0

your device older than minSDK , edit minSdkVersion in build.gradle

vuhung3990
  • 6,353
  • 1
  • 45
  • 44
0

One more place where minSdkVersion makes a sense is a flavor:

productFlavors {
    dev {
        minSdkVersion 22
    }
    prod {
        minSdkVersion 9
    }
}

minSdkVersion (22) will not install on development devices with API level older than 22.

0

you need update.

This is my current solution (09/2015).

In Android Studio search.

Menu --> Help --> check for update

Upate and problem solved!!

Good luck

David Hackro
  • 3,652
  • 6
  • 41
  • 61
0

Check the minimum API level inside the build.gradle(module: app)[inside of the gradle scripts]. Thatt should be equal to or lower than the device you use

Aditya
  • 110
  • 1
  • 8
0

In build.gradle change minSdkVersion 17 or later.

taskinoor
  • 45,586
  • 12
  • 116
  • 142