When you use 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 these two terms about android sdk version.
- minSdkVersion : This is the minimum versio of android os that your app support.
- targetSdkVersion : This is the android os version which your app actually executed with.
- You app should compatible with all the android os versions between minSdkVersion and targetSdkVersion.
1. Change Android SDK Version In Android Studio.
There are two method that can change android sdk version in android studio.
1.1 Change in build.gradle File.
- Select Project in Project view.
- Edit app / build.gradle file.
- Change minSdkVersion and targetSdkVersion in right panel.
1.2 Change In Project Structure Dialog.
- Click android studio menu ” File —> Project Structure “.
- In Project Structure dialog, select app in Modules list. Select Flavors tab in right panel, then you can select your desired android Min Sdk Version and Target Sdk Version.
- Click OK to save the selection.
- Click ” Build —> Rebuild Project ” menu item to rebuild the android project.
- This time the build.gradle file will be changed by android studio automatically.