更改API级别的Andr​​oid工作室级别、工作室、API、oid

由网友(Reincarnation.(轮回.))分享简介:我想从12 API改变最小的SDK版本的Andr​​oid Studio中的API 14.我曾在清单文件进行更改,即<使用-SDK安卓的minSdkVersion =14机器人:targetSdkVersion =18/>和重建项目,但我仍然得到Android的Studio IDE中抛出了一些错误。我pre...

我想从12 API改变最小的SDK版本的Andr​​oid Studio中的API 14.我曾在清单文件进行更改,即

 <使用-SDK
    安卓的minSdkVersion =14
    机器人:targetSdkVersion =18/>
 

和重建项目,但我仍然得到Android的Studio IDE中抛出了一些错误。我presume我必须设置分SDK在项目属性或类似的东西,所以在IDE识别的变化,但我找不到在哪里,这是在Android的工作室完成的。指针大大AP preciated。日Thnx。

解决方案

当你想更新的minSdkVersion在一个已经存在的项目...

更新的src / build.gradle - 确保下一个的src 文件夹

build.gradle的例子:

 应用插件:com.android.application

安卓{
    compileSdkVersion 23
    buildToolsVersion23.0.1

    defaultConfig {
        的applicationIDcom.stackoverflow.answer
        的minSdkVersion 16
        targetSdkVersion 23
        版本code 1
        VERSIONNAME1.0
    }
    buildTypes {
        推出 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'proguard-rules.pro
    }
}

依赖{
    androidTestCompile'的JUnit:JUnit的:4.12
    编译文件树(导演:库,包括:['的* .jar'])
}
 

同步摇篮按钮 重建项目

之后更新的 build.gradle 的的的minSdkVersion ,你必须按一下按钮同步摇篮文件(同步工程与摇篮文件)。这将清除该标志。

更新的的manifest.xml 的,因为如删除在清单文件SDK水平的任何引用,是没有必要再在Android的工作室。

这是所有乡亲。

I want to change the minimum SDK version in Android Studio from API 12 to API 14. I have tried changing it in the manifest file, i.e.,

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="18" />

and rebuilding the project, but I still get the Android Studio IDE throwing up some errors. I presume I have to set the min SDK in 'project properties' or something similar so the IDE recognises the change, but I can't find where this is done in Android Studio. Pointers greatly appreciated. Thnx.

解决方案

When you want to update your minSdkVersion in an existent project...

Update src/build.gradle - Make sure is the one under src folder

Example of build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

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

Sync gradle button Rebuild project

After updating the build.gradle's minSdkVersion, you have to click on the button to sync gradle file ("Sync Project with Gradle files"). That will clear the marker.

Updating manifest.xml, for e.g. deleting any references to SDK levels in the manifest file, is NOT necessary anymore in Android Studio.

That's all folks.

阅读全文

相关推荐

最新文章