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.
- minSdkVersion: This is the minimum version of android os that your app support.
- targetSdkVersion: This is the android os version which your app actually executed with.
- 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 android studio project build.gradle File.
- Select Project in android studio Project view.
- Edit <project-name>/app/build.gradle file.
- 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.
- Click the android studio menu ” File —> Project Structure “.
- In the Project Structure dialog, select the app in the Modules list on the left side. Select the Flavors tab on the right panel, click the defaultConfig item in the dialog center, then you can select your desired android Min Sdk Version and Target Sdk Version from the related dropdown list.
- Click the OK button to save the selection.
- Click the ” Build —> Rebuild Project ” menu item to rebuild the android project.
- This time the build.gradle file will be changed by android studio automatically.