Home > OS >  Android Studio What is the difference between minSdkVersion, targetSdkVersion and minSdk, targetSdk?
Android Studio What is the difference between minSdkVersion, targetSdkVersion and minSdk, targetSdk?

Time:12-06

I changed Target SDK Version from 30 to 31 and Min SDK Version from 19 to 22. In build.gradle, the minSdkVersion, targetSdkVersion and targetSdk change accordingly except for minSdk. It is still 19.

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.example.studentsacademicmanagementappsama"
        minSdk 19
        targetSdk 31
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        targetSdkVersion 31
        minSdkVersion 22
    }
} 
  • What is the difference between minSdkVersion, targetSdkVersion and minSdk, targetSdk?

  • Should I change minSdk to 22 or ignore it?

CodePudding user response:

There is no such thing named minSdk , targetSdk and compileSdk in build.gradle. you should config your app compatibility like this :

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.app.test"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0.0"
    }
}

CodePudding user response:

From what I can make out1, the Gradle plugin will not understand (and will ignore) these properties:

  minSdk 19
  targetSdk 31

From what I can make out, they have never been recognized.

Q: Why are they there?
A: My guess is that the person who wrote the original Gradle file made a mistake.

My suggestion would be to just remove them and see if it breaks anything.


1 - ... from reading the plugin documentation, looking at the source code and Googling. It is possible I have missed something.

  • Related