Changing API level Android Studio

前端 未结 14 1522
星月不相逢
星月不相逢 2020-11-22 09:01

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



        
14条回答
  •  野性不改
    2020-11-22 09:38

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

    1. 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 28
        buildToolsVersion "28.0.2"
    
        defaultConfig {
            applicationId "com.stackoverflow.answer"
            minSdkVersion 21
            targetSdkVersion 28
            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'])
    }
    
    1. Sync gradle button (refresh all gradle projects also works)

    For beginners in Android Studio "Sync gradle button" is located in Tools -> Android -> Sync Project with Gradle Files "Rebuild project" Build -> Rebuild Project

    1. 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.

提交回复
热议问题