Difference between revisions of "Android Studio: Ubah Setting SDK Minimum"

From OnnoWiki
Jump to navigation Jump to search
 
Line 16: Line 16:
 
When you want to update your minSdkVersion in an existent project...
 
When you want to update your minSdkVersion in an existent project...
  
    Update src/build.gradle - Make sure is the one under src folder
+
* Update src/build.gradle - Make sure is the one under src folder
  
 
Example of build.gradle:
 
Example of build.gradle:
Line 45: Line 45:
 
  }
 
  }
  
    Sync gradle button
+
* Sync gradle button
    Rebuild project
+
* 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.
 
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.
Line 53: Line 53:
  
 
That's all folks.
 
That's all folks.
 
 
  
 
==Referensi==
 
==Referensi==

Latest revision as of 05:51, 19 October 2015

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