Home Changing API level Android Studio
Reply: 13

Changing API level Android Studio

James B
1#
James B Published in 2013-10-19 10:31:57Z

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.

rogerdpack
2#
rogerdpack Reply to 2017-10-10 06:23:07Z

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 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'])
}
  1. Sync gradle button (refresh all gradle projects also works)
  2. 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.

Jamppa
3#
Jamppa Reply to 2013-10-27 09:49:17Z

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.

Chris Rolliston
4#
Chris Rolliston Reply to 2013-11-10 11:44:14Z

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

user3291001
5#
user3291001 Reply to 2014-02-10 00:29:09Z

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.

Community
6#
Community Reply to 2017-05-23 11:33:27Z

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.

Juan Reyes
7#
Juan Reyes Reply to 2014-05-07 18:16:23Z

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"

Sabri Meviş
8#
Sabri Meviş Reply to 2014-07-05 13:57:29Z

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"
}
Isuru
9#
Isuru Reply to 2015-12-06 06:36:34Z

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.

  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.

HexAndBugs
10#
HexAndBugs Reply to 2015-07-15 08:36:37Z

In android studio you can easily press:

  • Ctrl + Shift + Alt + S.
  • If you have a newer version of android studio than press on app first. than continue with step three as follows.
  • A window will open with a bunch of options
  • Go to Flavors and thats actually all you need

You can also change the versionCode of your app there.

nstCactus
11#
nstCactus Reply to 2016-05-20 08:51:49Z

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

Chris
12#
Chris Reply to 2016-07-01 15:10:20Z

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"
}
Hubert Hubert
13#
Hubert Hubert Reply to 2016-07-12 11:27:27Z

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

Rido
14#
Rido Reply to 2017-10-10 21:32:46Z

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
6. Click OK

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316321 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO