How to Change Target API Level 26 or Above in Android Studio

0
18259

Android API SDKYour app currently targets API level 25 and must target at least API level 26 to ensure it is built on the latest APIs optimized for security and performance.

If you see the error message don’t panic. Google has changed the Target API-level requirements for an Android app from August 2018.

Target API level requirements from August 2018
From August 2018, new apps must target at least Android 8.0 (API level 26). From November 2018, app updates must target Android 8.0 (API level 26).



Here is the solution

1) Change SDK API Level in Android Studio 

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

 

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

Change the Compile SDK Version and Build Tool Version to API-Level 26 and above



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

Change the Min Sdk Version as per your requirement, but Target Sdk version should be 26 or above. You can also set version code, name here.

Step 4 : Click Ok and Sync your Gradle.



2) To Change API using build.gradle (app level) in Android Studio

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

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

Note : I have used mobile instead of app in my project

 Step 2: Open the build.gradle and go to defaultConfig and set targetSdkVersion as shown below.

Step 3: Click on Sync Now.

PS: If you are doing the first method, it will automatically update your build.gradle. If it is not done automatically follow the second method too.

Follow us on Instagram and subscribe to Knowlab.