安装失败 [INSTALL_FAILED_OLDER_SDK] Android Studio

5

我是一名Android新手,正在使用Android Studio。我创建了一个新项目,只想展示“Hello World!”但是由于这个错误,我无法在AVD上运行它:Failure [INSTALL_FAILED_OLDER_SDK]。

我已经搜索过答案,我知道这涉及到build.gradle和minSdkVersion,但任何答案都没有对我起作用。

这是我的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>

以下是我的 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'])
}

我不仅希望得到答案,还要有解释。
谢谢!

4个回答

6

除非您确定要在应用程序中使用Android L开发者预览版,请不要针对它进行目标和编译。它仍然是一个预览版,似乎针对预览版进行目标和编译的应用程序会导致任何非L设备出现此错误。

更新您的build.gradle中的这些行以保持最新的稳定版本(Android 4.4,API 19):

android {
    compileSdkVersion 19

    defaultConfig {
        targetSdkVersion 19
    }
}

3
这个做法可行,但如果你在 ../res/values-v21 目录下有一个 styles.xml 文件,并且它引用了 android:Theme.Material.Light.DarkActionBar,就会弹出一个错误提示:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.DarkActionBar' - Cora

1

我解决了这个问题。我只是将compileSdkVersion从android_L修改为19,以针对我的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'
}

如何通过IDE修改值。 选择文件->项目结构->Facets->android-gradle,然后将编译SDK版本从android_L修改为19。抱歉,我没有足够的声望来添加图片。

1

我认为具有以下特点的项目:

 compileSdkVersion 'android-L'

目前无法在其他 Android 版本中安装。如果您没有使用 L 预览版 SDK 进行特定操作,只需将编译版本设置为官方版本之一即可。目标 SDK 同理。

您可以在“创建项目向导”中选择它们。


0
如果您在编译Adobe AIR移动应用程序时遇到此错误-只需在应用程序描述符xml文件中更正“minSdkVersion”这一行即可:
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="15"></uses-sdk> 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接