Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failure [INSTALL_FAILED_OLDER_SDK] Android Studio

Tags:

android

xml

sdk

I'm new to Android and I'm using the Android Studio. I've created a new project just to show the Hello World! but I can't get it working on the AVD because of this error: Failure [INSTALL_FAILED_OLDER_SDK].

I already searched for the answer and I know it's something about the build.gradle and the minSdkVersion but any of the answers worked for me.

This is my AndroidManifest.xml :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.scoelli.test" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MyActivity"
            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>

And this is my build.gradle :

apply plugin: 'com.android.application'

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

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

I would appreciate not only the answer but the explanation.

Thank You!

like image 338
Pantera96c Avatar asked Jul 01 '14 20:07

Pantera96c


3 Answers

Unless you know you want to be using the Android L developer preview with your application, do not target and compile with it. It is still very much a preview release, and it appears as though applications targeting and compiling for the preview cause this error with any non-L device.

Update these lines in your build.gradle to stick with the latest stable release (Android 4.4, API 19):

android {
    compileSdkVersion 19

    defaultConfig {
        targetSdkVersion 19
    }
}
like image 181
Bryan Herbst Avatar answered Oct 25 '22 12:10

Bryan Herbst


I fixed this problem. I just modified the compileSdkVersion 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

like image 33
Ant小波 Avatar answered Oct 25 '22 10:10

Ant小波


I think projects with

 compileSdkVersion 'android-L'

cannot be installed in other Android versions right now. I might be wrong there but if you're not doing anything specific to the L preview SDK, just set the compile version to one of the official ones. Same goes for the targetSdk.

You can choose those in the Create Project wizard.

like image 32
fweigl Avatar answered Oct 25 '22 11:10

fweigl