Changing API level Android Studio

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, ie,

<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 recognizes the change, but I can't find where this is done in Android Studio.


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

  • Update build.gradle(Module: app) - Make sure is the one under Gradle Script and it is NOT build.gradle(Project: yourproject) .
  • An example of build.gradle:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 26
        buildToolsVersion "25.0.3"
    
        defaultConfig {
            applicationId "com.stackoverflow.answer"
            minSdkVersion 21
            targetSdkVersion 26
            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 (refresh all gradle projects also works)
  • 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 eg deleting any references to SDK levels in the manifest file, is NOT necessary anymore in Android Studio.


    For android studio users:

  • right click the App directory
  • choose the "module setting" option
  • change the ADK Platform as what you need
  • Click Apply
  • The gradle will rebuild the project automatically.


    As now Android Studio is stable, there is an easy way to do it.

  • Right click on your project file
  • Select "Open Module Settings"
  • Go to the "Flavors" tab.
  • 在这里输入图像描述

  • Select the Min SDK Version from the drop down list
  • PS: Though this question was already answered but Android Studio has changed a little bit by its stable release. So an easy straight forward way will help any new answer seeker landing here.

    链接地址: http://www.djcxy.com/p/81604.html

    上一篇: 无法获取SHA1证书指纹Android Studio

    下一篇: 更改API级别的Android Studio