Как изменить minsdk android studio

I have been building a project and testing it on the Android emulator. I realized that I set the minSdkVersion to 10. Now, I have a phone to test the program on, but its sdk version is 7. I tri...

I have been building a project and testing it on the Android emulator.

I realized that I set the minSdkVersion to 10. Now, I have a phone to test the program on, but its sdk version is 7.

I tried to go into the manifest file, and change the sdk version to 7, but every time I run the program, it crashes.

How can I rebuild or change the sdk version to a lower number (from 10 to 7), so that I can make sure my app is able to run on older phones?

nbro's user avatar

nbro

14.8k29 gold badges108 silver badges193 bronze badges

asked Mar 25, 2011 at 0:19

Peter's user avatar

1

In your app/build.gradle file, you can set the minSdkVersion inside defaultConfig.

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.name.app"
        minSdkVersion 19    // This over here
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

answered Jun 23, 2016 at 20:25

juil's user avatar

juiljuil

2,3393 gold badges17 silver badges18 bronze badges

2

Set the min SDK version within your project’s AndroidManifest.xml file:

<uses-sdk android:minSdkVersion="4"/>

What exactly causes the crash? Iron out all crashes/bugs in minimum version and then test in higher versions.

answered Mar 25, 2011 at 0:29

Kon's user avatar

KonKon

26.9k11 gold badges59 silver badges86 bronze badges

3

This is what worked for me:

In the build.gradle file, setting the minSdkVersion under defaultConfig:

enter image description here

Good Luck…

answered Jan 21, 2019 at 7:23

Aakash's user avatar

AakashAakash

19.9k7 gold badges98 silver badges77 bronze badges

1

Create a new AVD with the AVD Manager and set the Target to API Level 7. Try running your application with that AVD. Additionally, make sure that your min sdk in your Manifest file is at least set to 7.

answered Mar 25, 2011 at 0:27

WindsurferOak's user avatar

WindsurferOakWindsurferOak

4,8411 gold badge29 silver badges36 bronze badges

1

check it: Android Studio->file->project structure->app->flavors->min sdk version
and if you want to run your application on your mobile you have to set min sdk version less than your device sdk(API)
you can install any API levels.

answered Nov 23, 2017 at 11:41

A.J's user avatar

A.JA.J

3111 gold badge2 silver badges7 bronze badges

Set the min SDK version in your project’s AndroidManifest.xml file and in the toolbar search for «Sync Projects with Gradle Files» icon. It works for me.

Also look for your project’s build.gradle file and update the min sdk version.

answered Dec 28, 2013 at 3:55

Christian Campodónico's user avatar

Open the app/build.gradle file and check the property field compileSdkVersion in the android section. Change it to what you prefer.

If you have imported external libraries into your application (Ex: facebook), then make sure to check facebook/build.gradle also.

spenibus's user avatar

spenibus

4,29911 gold badges25 silver badges35 bronze badges

answered Sep 6, 2015 at 6:04

Dharani Manne's user avatar

Delete this line:

<uses-sdk android:targetSdkVersion="..." />

in the file:

AndroidManifest.xml

answered Nov 21, 2018 at 11:57

user_MGU's user avatar

user_MGUuser_MGU

95811 silver badges11 bronze badges

If you use a cordova to build your app, for me the best soluction is change the argument cdvMinSdkVersion=15 to cdvMinSdkVersion=19 in the file platformsandroidgradle.properties

fcdt's user avatar

fcdt

2,3315 gold badges12 silver badges26 bronze badges

answered Aug 18, 2020 at 17:02

Alexandre Muzulão's user avatar

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.

Laurel's user avatar

Laurel

5,90314 gold badges30 silver badges56 bronze badges

asked Oct 19, 2013 at 10:31

James B's user avatar

8

When you want to update your minSdkVersion in an existing Android project…

  1. Update build.gradle (Module: YourProject) under Gradle Script and
    make sure that it is NOT build.gradle (Project: YourProject.app).

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

enter image description here
or
enter image description here

  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.

Terry's user avatar

Terry

9858 silver badges29 bronze badges

answered Nov 23, 2013 at 21:08

Sotti's user avatar

SottiSotti

13.9k2 gold badges50 silver badges43 bronze badges

12

Update 2022

For Android Studio users:

  1. Right click the App directory and
    Choose the «Open Module Settings» (F4) option
    Right click App then choose Open Module Settings

  2. Change the «Min SDK Version» in the Default Config tab
    Choose Min SDK Version
    NOTE:
    You might also want to change;
    the «Target SDK Version» in the Default Config tab and
    the «Compile SDK Version» in the Properties tab
    Choose Compile SDK Version

  3. Click Apply, then OK, and Gradle should automatically be synced


For users of older Android Studio versions:

  1. Right click the App directory and
    Choose the «Module Setting» (F4) option
  2. Change the ADK Platform to what you need
  3. Click OK and Gradle should automatically be synced

Ola Ström's user avatar

Ola Ström

3,5644 gold badges20 silver badges40 bronze badges

answered Feb 10, 2014 at 0:29

user3291001's user avatar

user3291001user3291001

1,9191 gold badge11 silver badges3 bronze badges

4

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.

Isuru's user avatar

Isuru

30.1k59 gold badges187 silver badges295 bronze badges

answered Dec 23, 2014 at 19:20

priyankvex's user avatar

priyankvexpriyankvex

5,6805 gold badges27 silver badges43 bronze badges

5

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.

Daniel's user avatar

Daniel

451 silver badge9 bronze badges

answered May 13, 2015 at 19:48

Salah Klein's user avatar

Salah KleinSalah Klein

3703 silver badges12 bronze badges

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"
}

answered Jul 5, 2014 at 13:57

Sabri Meviş's user avatar

Sabri MevişSabri Meviş

2,1011 gold badge30 silver badges34 bronze badges

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.

Community's user avatar

answered Apr 15, 2014 at 9:10

Meier's user avatar

MeierMeier

3,8381 gold badge17 silver badges46 bronze badges

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

AnneTheAgile's user avatar

AnneTheAgile

9,7566 gold badges50 silver badges48 bronze badges

answered Oct 10, 2017 at 21:32

Rido's user avatar

RidoRido

7174 gold badges10 silver badges22 bronze badges

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"

answered May 7, 2014 at 18:16

Juan Reyes's user avatar

Juan ReyesJuan Reyes

4045 silver badges9 bronze badges

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…

answered Nov 10, 2013 at 11:44

Chris Rolliston's user avatar

Chris RollistonChris Rolliston

4,7781 gold badge15 silver badges20 bronze badges

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

nstCactus's user avatar

nstCactus

5,0032 gold badges30 silver badges41 bronze badges

answered May 20, 2016 at 7:35

Dharmendra Pratap's user avatar

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

answered Feb 7, 2020 at 18:31

Wisam Atil's user avatar

Wisam AtilWisam Atil

811 silver badge9 bronze badges

When you want to change minimum SDK you should take care of minSdkVersion[About] in module build.garadle

android {
  defaultConfig {
    minSdkVersion 21
  }
}

answered May 30, 2021 at 14:02

yoAlex5's user avatar

yoAlex5yoAlex5

26.5k8 gold badges180 silver badges191 bronze badges

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"
}

answered Jul 1, 2016 at 15:10

Chris Deck's user avatar

Chris DeckChris Deck

1462 silver badges9 bronze badges

To change the minimum SDK version in Android Studio just…

1). Right click on «app» in the «Project» panel
Right click on "app"

2). Choose the new «Min SDK Version» on the «Default Config» tab
Choose the new "Min SDK Version" on the "Default Config" tab

3). Click on «OK» and the project will now resync with the new Gradle settings.

answered Sep 7, 2022 at 18:41

Snostorp's user avatar

SnostorpSnostorp

4687 silver badges12 bronze badges

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.

answered Oct 27, 2013 at 9:27

Jamppa's user avatar

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

answered Jul 12, 2016 at 11:27

Hubert Hubert's user avatar

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.

Laurel's user avatar

Laurel

5,90314 gold badges30 silver badges56 bronze badges

asked Oct 19, 2013 at 10:31

James B's user avatar

8

When you want to update your minSdkVersion in an existing Android project…

  1. Update build.gradle (Module: YourProject) under Gradle Script and
    make sure that it is NOT build.gradle (Project: YourProject.app).

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

enter image description here
or
enter image description here

  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.

Terry's user avatar

Terry

9858 silver badges29 bronze badges

answered Nov 23, 2013 at 21:08

Sotti's user avatar

SottiSotti

13.9k2 gold badges50 silver badges43 bronze badges

12

Update 2022

For Android Studio users:

  1. Right click the App directory and
    Choose the «Open Module Settings» (F4) option
    Right click App then choose Open Module Settings

  2. Change the «Min SDK Version» in the Default Config tab
    Choose Min SDK Version
    NOTE:
    You might also want to change;
    the «Target SDK Version» in the Default Config tab and
    the «Compile SDK Version» in the Properties tab
    Choose Compile SDK Version

  3. Click Apply, then OK, and Gradle should automatically be synced


For users of older Android Studio versions:

  1. Right click the App directory and
    Choose the «Module Setting» (F4) option
  2. Change the ADK Platform to what you need
  3. Click OK and Gradle should automatically be synced

Ola Ström's user avatar

Ola Ström

3,5644 gold badges20 silver badges40 bronze badges

answered Feb 10, 2014 at 0:29

user3291001's user avatar

user3291001user3291001

1,9191 gold badge11 silver badges3 bronze badges

4

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.

Isuru's user avatar

Isuru

30.1k59 gold badges187 silver badges295 bronze badges

answered Dec 23, 2014 at 19:20

priyankvex's user avatar

priyankvexpriyankvex

5,6805 gold badges27 silver badges43 bronze badges

5

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.

Daniel's user avatar

Daniel

451 silver badge9 bronze badges

answered May 13, 2015 at 19:48

Salah Klein's user avatar

Salah KleinSalah Klein

3703 silver badges12 bronze badges

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"
}

answered Jul 5, 2014 at 13:57

Sabri Meviş's user avatar

Sabri MevişSabri Meviş

2,1011 gold badge30 silver badges34 bronze badges

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.

Community's user avatar

answered Apr 15, 2014 at 9:10

Meier's user avatar

MeierMeier

3,8381 gold badge17 silver badges46 bronze badges

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

AnneTheAgile's user avatar

AnneTheAgile

9,7566 gold badges50 silver badges48 bronze badges

answered Oct 10, 2017 at 21:32

Rido's user avatar

RidoRido

7174 gold badges10 silver badges22 bronze badges

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"

answered May 7, 2014 at 18:16

Juan Reyes's user avatar

Juan ReyesJuan Reyes

4045 silver badges9 bronze badges

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…

answered Nov 10, 2013 at 11:44

Chris Rolliston's user avatar

Chris RollistonChris Rolliston

4,7781 gold badge15 silver badges20 bronze badges

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

nstCactus's user avatar

nstCactus

5,0032 gold badges30 silver badges41 bronze badges

answered May 20, 2016 at 7:35

Dharmendra Pratap's user avatar

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

answered Feb 7, 2020 at 18:31

Wisam Atil's user avatar

Wisam AtilWisam Atil

811 silver badge9 bronze badges

When you want to change minimum SDK you should take care of minSdkVersion[About] in module build.garadle

android {
  defaultConfig {
    minSdkVersion 21
  }
}

answered May 30, 2021 at 14:02

yoAlex5's user avatar

yoAlex5yoAlex5

26.5k8 gold badges180 silver badges191 bronze badges

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"
}

answered Jul 1, 2016 at 15:10

Chris Deck's user avatar

Chris DeckChris Deck

1462 silver badges9 bronze badges

To change the minimum SDK version in Android Studio just…

1). Right click on «app» in the «Project» panel
Right click on "app"

2). Choose the new «Min SDK Version» on the «Default Config» tab
Choose the new "Min SDK Version" on the "Default Config" tab

3). Click on «OK» and the project will now resync with the new Gradle settings.

answered Sep 7, 2022 at 18:41

Snostorp's user avatar

SnostorpSnostorp

4687 silver badges12 bronze badges

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.

answered Oct 27, 2013 at 9:27

Jamppa's user avatar

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

answered Jul 12, 2016 at 11:27

Hubert Hubert's user avatar

When you use the android widget in layout XML or java code, you may encounter error messages like Call requires API level 23 (current min is 17):. This means your current android minimum SDK version is 1.7, which is too low to use this widget. You need to change it to 23. This article will show you how to change it in android studio.

First, we should know the below two terms about the android SDK version.

  1. minSdkVersion: This is the minimum version of android os that your app support.
  2. targetSdkVersion: This is the android os version that your app actually executed.
  3. Your app should compatible with all the android os versions between minSdkVersion and targetSdkVersion.

1. Change Android SDK Version In Android Studio.

There are two methods that can change the android SDK version in android studio.

1.1 Change in the android studio project build.gradle File.

  1. Select Project in android studio Project view.
  2. Edit <project-name>/app/build.gradle file.
  3. Change minSdkVersion and targetSdkVersion in the right panel. You can search for it if you can not find it immediately.

1.2 Change in android studio project structure dialog.

  1. Click the android studio menu ” File —> Project Structure “.
  2. In the Project Structure dialog, select the app item in the Modules list on the left side.
  3. Select the tab Flavors on the right panel, click the defaultConfig item in the dialog center list area.
  4. Then you can select your desired android Min Sdk Version and Target Sdk Version from the related dropdown list on the right side.
    android-project-structure-dialog
  5. Click the OK button to save the selection.
  6. Click the ” Build —> Rebuild Project ” menu item to rebuild the android project.
  7. This time the build.gradle file will be changed by android studio automatically.

2. How To Change Android Studio Minimum Android SDK Version In Existing Android Project.

2.1 Question.

  1. Recently, when I open android studio to develop an android project, I find a red underline in the layout.xml file(2022/05/24).
  2. When I hover the mouse over the redline, it shows the message that a minimum API level of 18 is required.
  3. So I need to change the minimum Android SDK version to 18 in the android studio.
  4. I tried to change it in the manifest.xml file like the below code
    <uses-sdk
    android:minSdkVersion="18"
    android:targetSdkVersion="26" />
  5. But when I rebuild the android project, the error still exists.
  6. I also find that if I create a new android project in android studio and make the new project use android SDK version 18 as the minim SDK version, there is no error.
  7. The error only happens when I update the existing android project minimum SDK version number in the manifest.xml file.
  8. How can I do it in android studio?

2.2 Answer1.

  1. If you want to update an existing android project minSdkVersion number, you can not update it in the manifest.xml file.
  2. You should update the Gradle Scripts/build.gradle(Module: your_app) file in the android studio, make sure not to edit the Gradle Scripts/build.gradle(Project: your_project) file.
  3. Edit the minSdkVersion value in the Gradle Scripts/build.gradle(Module: your_app) file defaultConfig section like below.
    defaultConfig {
          ......
          minSdkVersion 18
          targetSdkVersion 26
          ......
    }
  4. Click the Sync Now button on the build.gradle file top right corner to make the change take effect.
  5. Or you can click the Tools —> Android —> Sync Project with Gradle Files to sync the changes.
  6. Then you can rebuild the android project and find the error has been fixed.

Basically, API level means the Android version. This defines for which version you are targeting your application and what is going to be the minimum level of android version in your application will run. For setting Minimum level and Maximum level android studio provides two terminologies.

minSdkVersion means minimum Android OS version that will support your app and targetSdkVersion means the version for which you are actually developing your application. Your app will be compatible with all the version of android which are falling between minimum level SDK and target SDK.


How to change API SDK level in Android Studio

For changing the API level in android we have two different Approaches, let’s check both one by one:

Approach 1 To Change SDK API Level in Android Studio:

Step 1: Open your Android Studio, and go to Menu. File >Project Structure.

project structure in Android Studio

Step 2: In project Structure window, select app module in the list given on left side.

Step 3: Select the Flavors tab and under this you will have an option for setting “Min Sdk Version” and for setting “Target Sdk Version”.

change api sdk level in Android Studio

You can check the name of version too in the drop down list while selecting the API level that makes the selection more clearer for anyone. Because sometimes remembering numbers is bit messy.

Step 4: Select both the versions and Click OK.


Approach 2 To Change API (Android Version) in Android Studio:

That will be pretty straight forward, but you need to stay very alert while making changes here.

Step 1: if you are project is opened in android option then select open Gradle Scripts > build.gradle(Module: app)

if you are in project View then click on your project folder > app > build.gradle

change sdk api level in build gradle android studio

Step 2: Here you have to change minimum and Maximum sdk level as per your requirement. check the below given code:

defaultConfig {
    applicationId "com.AbhiAndroid.Android.myProject"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

Step 3: Click on Sync Now and You are ready to go.

sync now change api sdk android studio

Note: If you are choosing the First Approach then you need not to make changes in Gradle. It will automatically update the gradle.

13 ответов

Если вы хотите обновить minSdkVersion в существующем проекте…

  • Обновить build.gradle(Module: app). Убедитесь, что он находится под Gradle Script, и он НЕ build.gradle(Project: yourproject).

Пример 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. Кнопка синхронизации gradle (обновлены все проекты gradle)
  2. Реконструкция проекта

После обновления build.gradle minSdkVersion вам нужно щелкнуть по кнопке, чтобы синхронизировать файл gradle ( «Синхронизировать проект с gradle файлами» ). Это очистит маркер.

Обновление manifest.xml, например. удаление каких-либо ссылок на уровни SDK в файле манифеста больше не требуется в Android Studio.

Sotti
23 нояб. 2013, в 22:19

Поделиться

Для пользователей студии Android:

  • щелкните правой кнопкой мыши каталог приложения
  • выберите параметр «настройка модуля»
  • измените платформу ADK как то, что вам нужно
  • Нажмите «Применить»

gradle автоматически перестроит проект.

user3291001
10 фев. 2014, в 01:05

Поделиться

Как сейчас Android Studio стабильна, есть простой способ сделать это.

  • Щелкните правой кнопкой мыши файл проекта
  • Выберите «Открыть настройки модуля»
  • Перейдите на вкладку «Ароматизаторы».

Изображение 109416

  1. Выберите Min SDK Version из выпадающего списка

PS: Хотя на этот вопрос уже был дан ответ, но Android Studio немного изменила его стабильный выпуск. Таким образом, простой прямой способ поможет любому новому поиску ответа приземлиться здесь.

priyankvex
23 дек. 2014, в 19:35

Поделиться

В студии Android вы можете легко нажать:

  • Ctrl + Shift + Alt + S.
  • Если у вас есть более новая версия android studio, чем сначала нажмите на приложение.
    чем продолжить с шага 3 следующим образом.
  • Откроется окно с набором параметров
  • Перейдите в Flavors, и на самом деле все, что вам нужно

Вы также можете изменить versionCode вашего приложения.

Salah Klein
13 май 2015, в 20:51

Поделиться

В build.gradle измените minSdkVersion 13 на minSdkVersion 8. Это все, что вам нужно сделать. Я решил свою проблему, только делая это.

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

Sabri Meviş
05 июль 2014, в 15:01

Поделиться

В соответствии с этим ответом вы просто не включаете minsdkversion в файл manifest.xml, а система сборки будет использовать значения из файла build.gradle и поместите информацию в окончательный apk.

Поскольку система сборки нуждается в этой информации, это имеет смысл. Вам не нужно указывать эти значения два раза.

Вам просто нужно синхронизировать проект после изменения файла build.gradle, но Android Studio 0.5.2 отображает желтую строку состояния поверх окна редактора build.gradle, чтобы помочь вам

Также обратите внимание на наличие как минимум двух файлов build.gradle: один мастер и один для приложения/модуля. Тот, который нужно изменить, находится в приложении/модуле, он уже включает свойство minSdkVersion во вновь сгенерированном проекте.

Meier
15 апр. 2014, в 09:38

Поделиться

Если у вас возникли проблемы с указанием целевой SDK для API Google вместо базового пакета SDK, просто измените compileSdkVersion 19 на compileSdkVersion "Google Inc.:Google APIs:19"

Juan Reyes
07 май 2014, в 18:16

Поделиться

Также, как и обновление манифеста, обновите файл модуля build.gradle тоже (он указан в панели проекта чуть ниже манифеста — если там нет minSdkVersion), вы смотрите на неправильный, так как там пара). Перестроить и все должно быть хорошо…

Chris Rolliston
10 нояб. 2013, в 13:25

Поделиться

Для последней версии Android Studio v2.3.3 (11 октября 2017 года):
 1. Нажмите View в строке меню
 2. Нажмите «Открыть настройки модуля»
 3. Откройте вкладку Flavors
 4. Выберите Min Sdk версию, которая вам нужна
 Изображение 109417
 6. Нажмите OK

Rido
10 окт. 2017, в 22:14

Поделиться

Gradle Скрипты →
build.gradle(модуль: приложение) →
minSdkVersion (Your min sdk version)

Hubert Hubert
12 июль 2016, в 11:32

Поделиться

Изменение minSdkVersion в манифесте не требуется. Если вы измените его в файле сборки gradle, как показано ниже, вы выполните то, что вам нужно сделать.

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

Chris
01 июль 2016, в 15:58

Поделиться

В студии Android откройте build.gradle и отредактируйте следующий раздел:

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

здесь вы можете изменить minSdkVersion от 12 до 14

Dharmendra Pratap
20 май 2016, в 08:00

Поделиться

Для меня работал: (щелчок правой кнопкой мыши) project- > инструменты android- > clear lint markers. Хотя по какой-то причине Manifest вернулась к старому (более низкому) уровню API, но после того, как я изменил ее на новый (более высокий) уровень API, не было подчеркивания красной ошибки, и теперь проект использует новый минимальный уровень API.

Изменить: Извините, я вижу, что вы использовали Android Studio, а не Eclipse. Но я думаю, что в Studio есть похожие «четкие метки метки», и это может решить проблему.

Jamppa
27 окт. 2013, в 10:58

Поделиться

Ещё вопросы

  • 0статья получит неправильные категории в красноречивом laravel 5.5
  • 1Не удалось установить кнопку под MapView
  • 0Обновить файл RSS из другого файла XML
  • 0JQuery действует странно в IE, когда я НЕ в режиме совместимости
  • 0динамический URL для JQuery TabPanel
  • 0Рут в Yii2 не работает
  • 1Изменение ImageView по нажатию кнопки
  • 1Как изменить, чтобы панели с вкладками менялись каждые несколько секунд?
  • 1Как добавить внешние файлы JS в проект Zurb Foundation 6.4 (веб-пакет)?
  • 1DirectorySeparatorChar.ToString () не показывает символ «иена» в японской культуре
  • 0Получить список результатов и получить сумму в одном запросе
  • 0STL установить найти производительность
  • 1Создание Discord Bot в Python: Как сделать разговор о переключателе для ChatBot
  • 1загрузите form2 через пару секунд и закройте form1
  • 0Цикл логики ловит неизвестное предельное значение
  • 1Загрузка файлов в Python
  • 0Как отобразить данные множественного выбора массива в поле выбора в angularjs в остальные API
  • 1Из JSON в XML и обратно в Java
  • 0Компилятор Intel: что означает ошибка «неизвестный тип в IL-обходе»?
  • 0Сортировка на поле varchar как целое число в MySQL
  • 0Как узнать, доступен ли уровень отладки dx?
  • 0symfony2 рендеринг формы как тип формы
  • 0MySQL не хранит микросекунды в datetime, но использует в где условия?
  • 0PHP генерирует категорию и подкатегорию из базы данных [дубликаты]
  • 0код индикатора загрузки не работает в jquery 1.10
  • 0Как получить событие, когда полоса прокрутки angularjs ui-grid достигает конца
  • 0Как конвертировать PHP Photo Upload / изображения для PHP видео загрузки / видео?
  • 0jQuery Получить значения из функции
  • 1Как создать заголовок запроса авторизации?
  • 1Как извлечь сообщения журнала приложения Android во время выполнения?
  • 0SoapUI — Сервис не возвращает операций
  • 1Как кластеризовать несколько строк с хотя бы одним и тем же значением в python?
  • 0Конструктор запросов — codeigniter
  • 0Применение css n-го потомка к угловому сгенерированному html
  • 1В карточной игре Java, как бы я ненадолго остановился после раздачи каждой карты в руку?
  • 0Как проверить совместимость jquery cookie.js?
  • 1Android: где я могу найти startSubActivity ()?
  • 1Java GUI Запись в текстовой области
  • 1GridBagLayout выровнять по левому краю
  • 0Журнал ошибок PHP с ошибкой URL
  • 0Запрос = неизвестная системная переменная ‘c3’
  • 0Туннельный шейдер (преобразован из WebGL в OpenGL) — координаты текстуры не совпадают?
  • 1Необходим ли bindService для локального (того же процесса) сервиса?
  • 1Использование цветовых карт с набором данных Iris в pyplot matplotlib дает ошибку
  • 0Должен ли я хранить настройки приложения в одном массиве столбцов? или создать таблицу из нескольких столбцов?
  • 0flexanimate работает только один раз
  • 1Реализация гравитации в простой 2d игре
  • 0CKeditor с несколькими динамическими текстовыми областями
  • 0Как я могу сделать jQuery .each fadeOut и fadeIn «слайдером»?
  • 0Как разместить текст после эскизов внизу?

Вот ошибка которая вылазит
ERROR: Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [androidx.camera:camera-core:1.0.0-alpha02] C:UsersUSER.gradlecachestransforms-2files-2.184f22891c3330b1e0bbdca99b7730947camera-core-1.0.0-alpha02AndroidManifest.xml as the library might be using APIs not available in 19
Suggestion: use a compatible library with a minSdk of at most 19,
or increase this project’s minSdk version to at least 21,
or use tools:overrideLibrary=»androidx.camera.core» to force usage (may lead to runtime failures) помогите!!!


  • Вопрос задан

    более двух лет назад

  • 734 просмотра

Пригласить эксперта

1. build clear project
2. manifest.xml

<manifest>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
<application
tools:overrideLibrary="androidx.camera.core"
/>
</manifest>

3. build.gradle.kts

defaultConfig {
        minSdk = 21
        targetSdk = 30
    }

3. invalide cache restart


  • Показать ещё
    Загружается…

10 февр. 2023, в 13:40

75000 руб./за проект

10 февр. 2023, в 13:27

2000 руб./за проект

10 февр. 2023, в 13:18

150000 руб./за проект

Минуточку внимания

Понравилась статья? Поделить с друзьями:
  • Как изменить lpt порт на com
  • Как изменить logon server
  • Как изменить logon screen windows 10
  • Как изменить login skype
  • Как изменить log на txt