compileSdkVersion, targetSdkVersion, minSdkVersion, gradle file, android gradle

Differences between compile, target and min Sdk Versions in android

In all projects that you are working on in android, you must come across the terms compileSdkVersion, targetSdkVersion, and minSdkVersion which sometimes as a developer you want to understand what each represents.

In this article, we will help you understand what compileSdkVersion, targetSdkVersion, and minSdkVersion mean and what are the major differences between each, where each is used, and how each is used.

Where is compileSdkVersion, targetSdkVersion and minSdkVersion found

First, you will need to understand that compileSdkVersion, targetSdkVersion, and minSdkVersion are found in the build.gradle file for the app in the Gradle scripts section.

This means that all of them are applicable to a module or specific app meaning they are not project-based but their configurations are only used in a specific module

Differences between compileSdkVersion, targetSdkVersion and minSdkVersion in android

An example of how compileSdkVersion, targetSdkVersion and minSdkVersion appears in the build.gradle file for app is as below

android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.kotlinexample"
minSdkVersion 22
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

In the above snippet, the compileSdkVersion is 29, while minSdkVersion is 22 and targetSdkVersion is 29.

With the values provided above it is noted that both compileSdkVersion and targetSdkVersion have the same values. We now discuss each version so that we can understand what each stands for.


compileSdkVersion is used to define the SDK version which your app will be compiled into by the Gradle.

You will notice that not all applications run on all mobile devices simply because the features added to the app are not supported in the version added to the android device.

From the above code snippet, you will note that compileSdkVersion is placed separately from others since it is used to tell the Gradle to build the app selected with the specified SDK version.

The reason why you must define the compileSdkVersion is simply that each version has different features that do not work in all devices therefore, defining the compileSdkVersion will ensure that Gradle checks whether the specified properties are supported by the said version.

If the compileSdkVersion defined is not supported in your android studio project, the project will either fail to build or you will get compile-time errors.

Therefore you will be required to update the compileSdkVersion to a version that your app supports or add the features for the specified SDK version.


targetSdkVersion simply means defining the audience you are developing the app for, that is, each android device belongs to a certain version and the version is associated with an API level and a name as shown below

Version Code

Version Name

API Level































In the targetSdkVersion, you add the API level which the compiler will translate to the version code and it will know that the app targets devices that are of that version.

The app will work in the other devices that are not of the specified API level but not as the targetSdkVersion defined.

To use a higher targetSdkVersion, you must ensure that you have added the dependencies or properties that are supported in that version.

To target, a larger audience and the latest devices ensure that you set the targetSdkVersion to the latest API level, that is, either 30 or 31.


The minSdkVersion simply defines a limit that can use the application that you have created.

With targetSdkVersion, you define the exact device that you want your app to built to but with minSdkVersion you define the least device that your app can be supported.

The minSdkVersion limit keeps on changing depending on how android regulates it since some earlier versions are no longer supported.

From the table we displayed above, the least version code supported is 5 meaning that the minSdkVersion should not be less than 22.

When you set the minSdkVersion too close to targetSdkVersion it means that you are limiting a lot of devices from supporting the applications


With the above discussion, we have noted that compileSdkVersion tells the Gradle which version it should build the application on while targetSdkVersion defines the specific device which the application is built for while minSdkVersion defines the least version of API level that your application supports.

That’s it for this article, hope you can now work with the three terms found in app gradle with ease.