Changing API level Android Studio

2018-12-31 14:38发布

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.

14条回答
人间绝色
2楼-- · 2018-12-31 15:17

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.

查看更多
公子世无双
3楼-- · 2018-12-31 15:18

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

查看更多
墨雨无痕
4楼-- · 2018-12-31 15:18

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.

查看更多
只靠听说
5楼-- · 2018-12-31 15:18

What worked for me:

I had renamed one of my imageViews and was still referencing the old imageView name in a textView later on:

In my code I changed:

app:layout_constraintStart_toStartOf="@id/imageView3"

to

app:layout_constraintStart_toStartOf="@id/myImageView"

And rebuilt the project. I don't know why this fixed the resource linking problem, but it fixed it.

查看更多
闭嘴吧你
6楼-- · 2018-12-31 15:24

In android studio you can easily press:

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

You can also change the versionCode of your app there.

查看更多
何处买醉
7楼-- · 2018-12-31 15:25

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

查看更多
登录 后发表回答