android api level, increase api level, change API level in android studio, check api level in android,

How to change API level in android studio for an app

In android API level simply means the android version. The API level defines the intended version of android phones that your application is simply targeting.

As we all know, android keeps on inventing new features and also updating the current features that are there for android phones.

When a new feature is introduced or an existing feature updated, android compiles it to a new version. As of December 2021, the current version of android is Android 12.

In this article, we shall focus on how to check API level in android studio for your app project and also show you how you can change the API level in android studio for your project to fit the minimum required by android

While working with the android studio to develop projects that will be rolled or published in the google play store, you have to meet some requirements and one of them is setting the API level that defines the target device version of android

The list below shows the last android versions from android version 5 to android version 12 with their version name and API level

Version Code

Version Name

API Level

5.1

Lollipop

22

6.0

Marshmallow

23

7.0

Nougat

24

7.1

Nougat

25

8.0.0

Oreo

26

8.1.0

Oreo

27

9

Pie

28

10

Android10

29

11

Android11

30

12

Android12

31

 

When you define the API level as it is demonstrated above, you are simply defining the app you are targeting the app for

To define a broad audience of whom you want your app to be compatible with you add minSdkVersion which defines the least version of android that your app should be compatible with

To define the specific version of Android that your app is targeting, use the targetSdkVersion

Also, when your app is being compiled, you need to add the settings and tell android the SDK version that you want to run on by using compileSdkVersion

How to check API level in android studio

To check the API level of your app in android studio;

  • Open your project in android studio
  • Navigate to Gradle scripts in the left section in android studio
  • Click to open build.gradle for project
  • Once build.gradle for app is open, you will see minSdkVersion, targetSdkVersion and compileSdkVersion

An example of build.gradle file for app is as follows

plugins {

    id 'com.android.application'

    id 'kotlin-android'

}

 

android {

    compileSdkVersion 29

 

    defaultConfig {

        applicationId "com.example.checkinternet"

        minSdkVersion 22

        targetSdkVersion 29

        versionCode 1

        versionName "1.0"

 

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

 

    buildTypes {

        release {

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }

    }

    compileOptions {

        sourceCompatibility JavaVersion.VERSION_1_8

        targetCompatibility JavaVersion.VERSION_1_8

    }

    kotlinOptions {

        jvmTarget = '1.8'

    }

}

 

dependencies {

 

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'androidx.core:core-ktx:1.7.0'

    implementation 'androidx.appcompat:appcompat:1.3.1'

    implementation 'com.google.android.material:material:1.4.0'

    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'

    testImplementation 'junit:junit:4.+'

    androidTestImplementation 'androidx.test.ext:junit:1.1.3'

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}

From the above build.gradle file, it is clear that the target SDK version which is the API level is 29 meaning the app project is being developed for the android 10 version of android phones.

To ensure that other phones that are less than the target SDK version are not left out and the app will work on them, we define the minSdkVersion and from the above Gradle file, the minimum API level targeted is API level 22 meaning the app is compatible with android phones that are above version 5

 How to change API level in android studio

Suppose you note that the versions or API levels set on your app project are not recommended or your app is not targeting the audience you want to reach, it is recommended you change the API level for your app project

As android continues advancing its features, the google play store will not be accepting apps that are targeting lower than API level 30 so it’s always recommended to be on the recommended list.

To change the API level, you will need to change minSdkVersion, targetSdkVersion, and compileSdkVersion in build.gradle file to the API levels that are recommended and the ones favoring your project

Please note you should not use values that are lower than the ones already defined in build.gradle file

Change the values in these fields and click sync

  • minSdkVersion 22
  • targetSdkVersion 30
  • compileSdkVersion 30

When the sync is successful, your app should apply the changes and build.gradle file should change and be like the one shown below

android {

    compileSdkVersion 30

 

    defaultConfig {

        applicationId "com.example.checkinternet"

        minSdkVersion 22

        targetSdkVersion 30

        versionCode 1

        versionName "1.0"

 

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

 

Conclusion

In the above discussion, we have shown the different types of android versions with their API levels and what they mean.

We have also shown you how to check the API level that your app project is in and also finally shown how to change the API level for your project

Hope you have learned a lot. Keep following us for more articles