如何在Android Studio中设置早期的Android SDK版本

时间:2016-07-12 17:08:26

标签: android android-studio

我是Android新手。我从其他人那里得到了一个项目,在build.gradle中有minSDKversion = 16和targetSdkVersion = 23

我在安装Android Studio时安装了android sdk 24。我希望我需要下载Android SDK 23并在Android Studio中引用它,但是经过多次阅读后我还没有发现如何做到这一点。

如果我想确保早期的Android版本/ Android API无法运行,我是否需要安装早期的SDK?

 Cause: failed to find target with hash string 'android-23' 

此外,我意识到我可以在Android Studio中引用版本23 sdk路径,但我无法在任何地方找到它。

由于

2 个答案:

答案 0 :(得分:1)

你只需要有目标sdk,这样就可以安装目标sdk,在你的情况下是23:

  

工具> Android> SDK Manager>启动Standalone SDK Manager

现在点击目标API版本下的 SDK平台并安装它。(如屏幕截图所示)

完成!

以下是独立SDK管理器的屏幕截图:

Standalone SDK Manager

<强>更新

以下是如何查找SDK Manager:

enter image description here

答案 1 :(得分:1)

安装SDK 23版本或: 更新build.Gradle(模块:app) - 确保是Gradle脚本下的那个并且它不是build.Gradle(Project:yourproject)  例如:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.stackoverflow.answer"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dependencies {
    androidTestCompile 'junit:junit:4.12'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
相关问题