minSdk vs targetSdk vs compileSdk

What is the difference between minSdk, targetSdk and compileSdk in your build Gradle script?

Vincent Tsen

--

Let’s have a look at what minSdk, targetSdk and compileSdk really means in build.gradle script.

android {
compileSdk 32
defaultConfig {
/*...*/
minSdk 21
targetSdk 32
/*...*/
}
}
  • minSdk — What is the minimum API Level required for the app to run?
  • targetSdk — Which API level the app was designed and tested on?
  • compileSdk — Which API level is used by Gradle to compile your app?

minSdk

If your minSdk is set to 21, your app cannot be run on any Android version that is below API level 21. If the Android version (API level 20) attempts to install your app, you get this error.

Installation did not succeed. The application could not be installed: INSTALL_FAILED_OLDER_SDK

The Google Play Store prevents the user from installing the app too if the phone’s Android version doesn’t meet the minSdk requirement by the app.

targetSdk

App runs on API level >…

--

--