如何在Android Studio中更改minSdk版本?

时间:2014-08-09 19:22:47

标签: android android-studio

我正在尝试在手机上运行一个基本的hello world程序,但是当我指定14时,Android Studio会继续恢复到minSDK 20级。这是我正在使用的过程:

- 启动Android Studio 0.8.2
- 选择新项目
- 选择最低SDK作为API 14:Android 4.0
- 选择空白活动
- 新项目现已开放。我的Android设备,运行4.4.2 API 19插入。
- 选择“运行应用程序”
- “选择设备”对话框打开,显示我的Android设备,但显示兼容性为No, minSdk(API 20, L preview)!= deviceSdk(API19)

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

将'compileSdkVersion'更改为14会导致错误,“找不到目标android-14”。

有什么想法吗?谢谢!

2 个答案:

答案 0 :(得分:4)

“L”开发者预览版是一种特殊的雪花,它打破了版本管理的所有常规规则。 : - (

除非您是专门针对“L”进行测试的有经验的Android开发人员,否则请将compileSdkVersion更改为19(注意:可能需要您从SDK Manager下载API级别19的SDK平台)并将targetSdkVersion更改为19

  

将'compileSdkVersion'更改为14会导致错误,“找不到目标android-14”。

您需要在SDK Manager中下载API Level 14“SDK Platform”。

答案 1 :(得分:1)

试试这个:

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'
    }
}
}

如果目标一直给你这个问题,试试像CommonsWare这样的较低版本说!