4

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?

Irfan
  • 77
  • 1
  • 9
  • Did you read the [blog post on picking your sdk levels](https://medium.com/androiddevelopers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd)? – ianhanniballake Dec 05 '21 at 07:17
  • 1
    I know what minSdkVersion and targetSdkVersion is. My problem is with minSdk and targetSdk. I watch a Youtube video on how to change SDK level and their build.gradle does not have minSdk and targetSdk but they have minSdkVersion and targetSdkVersion – Irfan Dec 05 '21 at 07:37
  • being duplicate of https://stackoverflow.com/questions/4568267/android-min-sdk-version-vs-target-sdk-version – Roll no1 Dec 05 '21 at 07:38
  • 2
    @Rollno1 no it is not. My problem is with minSdk and targetSdk not minSdkVersion and targetSdkVersion – Irfan Dec 05 '21 at 07:42

2 Answers2

2

As of the Android Gradle Plugin released in July 2021, you can use either minSdk or minSdkVersion, targetSdk or targetSdkVersion, compileSdk or compileSdkVersion. Why they did this, I'm not sure.

More details on this better answer over here: https://stackoverflow.com/a/67251145/467509

georgiecasey
  • 21,793
  • 11
  • 65
  • 74
-1

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"
    }
}
Ali Babadi
  • 114
  • 9
  • 1
    That is weird. This is the first time I touch the defaultConfig in build.gradle and I never made those changes. I am using Android Studio 2020.3.1 Is it a bug? – Irfan Dec 05 '21 at 07:56
  • That's weird to me. try to create new project and see if its happen again. – Ali Babadi Dec 05 '21 at 07:58
  • I did and the same thing happen again – Irfan Dec 05 '21 at 08:04
  • 1
    Same here, a fresh new project created with Android Studio Chipmunk 2021.2.1 Patch 2 has `minSdk` and `targetSdk` instead of `minSdkVersion` and `targetSdkVersion`. And you can find some open source projects on GitHub using those spellings: https://sourcegraph.com/search?q=context:global+file:build.gradle+lang:Gradle+%22minSdk+%22&patternType=standard – gustavopch Sep 14 '22 at 15:15