Android Studio: Ubah Setting SDK Minimum

From OnnoWiki
Jump to navigation Jump to search

Sumber: http://stackoverflow.com/questions/19465049/changing-api-level-android-studio

Edit manifest file

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

Dalam <manifest> tag, tapi BUKAN dalam <application> tag

Atau

up vote 233 down vote accepted


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.

Referensi