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

This question is related to android android-studio sdk android-api-levels

The answer is


If you're having troubles specifying the SDK target to Google APIs instead of the base Platform SDK just change the compileSdkVersion 19 to compileSdkVersion "Google Inc.:Google APIs:19"


Changing the minSdkVersion in the manifest is not necessary. If you change it in the gradle build file, as seen below, you accomplish what you need to do.

defaultConfig {
   applicationId "com.demo.myanswer"
   minSdkVersion 14
   targetSdkVersion 23
   versionCode 1
   versionName "1.0"
}

For android studio users:

  1. right click the App directory
  2. choose the "module setting" option
  3. change the ADK Platform as what you need
  4. Click Apply

The gradle will rebuild the project automatically.


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

  1. Right click on your project file
  2. Select "Open Module Settings"
  3. Go to the "Flavors" tab.

enter image description here

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


For me what worked was: (right click)project->android tools->clear lint markers. Although for some reason the Manifest reverted to the old (lower) minimum API level, but after I changed it back to the new (higher) API level there was no red error underline and the project now uses the new minimum API level.

Edit: Sorry, I see you were using Android Studio, not Eclipse. But I guess there is a similar 'clear lint markers' in Studio somewhere and it might solve the problem.


As well as updating the manifest, update the module's build.gradle file too (it's listed in the project pane just below the manifest - if there's no minSdkVersion key in it, you're looking at the wrong one, as there's a couple). A rebuild and things should be fine...


According to this answer, you just don't include minsdkversion in the manifest.xml, and the build system will use the values from the build.gradle file and put the information into the final apk.

Because the build system needs this information anyway, this makes sense. You should not need to define this values two times.

You just have to sync the project after changing the build.gradle file, but Android Studio 0.5.2 display a yellow status bar on top of the build.gradle editor window to help you

Also note there at least two build.gradle files: one master and one for the app/module. The one to change is in the app/module, it already includes a property minSdkVersion in a newly generated project.


Gradle Scripts ->
build.gradle (Module: app) ->
minSdkVersion (Your min sdk version)


In android studio you can easily press:

  1. Ctrl + Shift + Alt + S.
  2. If you have a newer version of android studio, then press on app first. Then, continue with step three as follows.
  3. A window will open with a bunch of options
  4. Go to Flavors and that's actually all you need

You can also change the versionCode of your app there.


For the latest Android Studio v2.3.3 (October 11th, 2017) :
1. Click View on menu bar
2. Click Open Module Settings
3. Open Flavors tab
4. Choose Min Sdk version you need
IDE Project Structure Window 6. Click OK


File>Project Structure>Modules you can change it from there


In build.gradle change minSdkVersion 13 to minSdkVersion 8 Thats all you need to do. I solved my problem by only doing this.

defaultConfig {
    applicationId "com.example.sabrim.sbrtest"
    minSdkVersion 8
    targetSdkVersion 20
    versionCode 1
    versionName "1.0"
}

In Android studio open build.gradle and edit the following section:

defaultConfig {
    applicationId "com.demo.myanswer"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

here you can change minSdkVersion from 12 to 14


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to sdk

I am receiving warning in Facebook Application using PHP SDK Has been compiled by a more recent version of the Java Runtime (class file version 57.0) Difference between OpenJDK and Adoptium/AdoptOpenJDK Error:Failed to open zip file. Gradle's dependency cache may be corrupt Can't accept license agreement Android SDK Platform 24 Automatically accept all SDK licences Android SDK location should not contain whitespace, as this cause problems with NDK tools Android SDK folder taking a lot of disk space. Do we need to keep all of the System Images? "The following SDK components were not installed: sys-img-x86-addon-google_apis-google-22 and addon-google_apis-google-22" Can't find SDK folder inside Android studio path, and SDK manager not opening

Examples related to android-api-levels

Changing API level Android Studio Get Android API level of phone currently running my application Retrieving Android API version programmatically