简体   繁体   English

Android Studio中的编译器sdk版本和目标sdk版本更改

[英]compiler sdk version and target sdk version change in Android studio

I installed Android Studio 1.4 .By default it has settings for compiler sdk and target sdk as MARSHMALLOW . 我安装了Android Studio 1.4。默认情况下,它的编译器sdk和目标sdk的设置为MARSHMALLOW。 So if i generated final APK after completion of my project, is it works in previous versions of android with out any error ..?? 因此,如果我在完成项目后生成了最终APK,它是否可以在android的早期版本中正常工作而没有任何错误.. ??

No Absolutely Not 绝对不是

To work fine you have to mention target sdk like 为了正常工作,您必须提及目标SDK

    minSdkVersion 19
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"

in Manifest file OR in build.gradle file. 在清单文件中或在build.gradle文件中。

My build.gradle contains 我的build.gradle包含

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.everestek.login"
    minSdkVersion 19

    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

} }

Your compile SDK version must match the support library's major version. 您的编译SDK版本必须与支持库的主要版本匹配。

Since you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. 由于您使用的是支持库的版本23,因此需要针对Android SDK的版本23进行编译。

Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22. 或者,您可以通过切换到最新的支持库v22继续针对Android SDK版本22进行编译。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'    
}

它将完美运行。您所要做的只是将minSdkVersion更改为16或您想要扩展支持的任何级别.Compile SDK版本是用于使用构建工具进行编译的。它没有问题。您可以为较早的版本提供支持设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM