Differencebetween Min Sdk Version/Target Sdk Version VS. Compile Sdk Version

What is the difference between min SDK version/target SDK version vs. compile SDK version?

The min sdk version is the earliest release of the Android SDK that your application can run on. Usually this is because of a problem with the earlier APIs, lacking functionality, or some other behavioural issue.

The target sdk version is the version your application was targeted to run on. Ideally, this is because of some sort of optimal run conditions. If you were to "make your app for version 19", this is where that would be specified. It may run on earlier or later releases, but this is what you were aiming for. This is mostly to indicate how current your application is for use in the marketplace, etc.

The compile sdk version is the version of android your IDE (or other means of compiling I suppose) uses to make your app when you publish a .apk file. This is useful for testing your application as it is a common need to compile your app as you develop it. As this will be the version to compile to an APK, it will naturally be the version of your release. Likewise, it is advisable to have this match your target sdk version.

What is the difference between compileSdkVersion and targetSdkVersion?

compileSdkVersion

The compileSdkVersion is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. If you set compileSdkVersion to 16 you can still run the app on a API 15 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 16.

targetSdkVersion

The targetSdkVersion has nothing to do with how your app is compiled or what APIs you can utilize. The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify. This is more like a certification or sign off you are giving the Android OS as a hint to how it should handle your app in terms of OS features.

For example, as the documentation states:

For example, setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher...

The Android OS, at runtime, may change how your app is stylized or otherwise executed in the context of the OS based on this value. There are a few other known examples that are influenced by this value and that list is likely to only increase over time.

For all practical purposes, most apps are going to want to set targetSdkVersion to the latest released version of the API. This will ensure your app looks as good as possible on the most recent Android devices. If you do not specify the targetSdkVersion, it defaults to the minSdkVersion.

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

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"
}
}

what is the difference between min sdk , target sdk and compile with ? in android

Simply,

Minimun SDK : API 14

refers that that your application will only run on mobile phone with api level 14 ie.(ICS 4.0) or higher. Your app will fail to run on previous versions of android like gingerbread & froyo.

Target SDK : API 17

refers to the version of android you want to build for, which is Jellybean on your case. It is recommended to keep latest as far as possible which is (api 20 Kitkat at present context).

Compile With : API 14

refers to version of andriod you are testing on. Complile with api 14 means you are going to test your app on ICS.

you could also watch this video:

https://www.youtube.com/watch?v=Sxo5zMcOCXM>

Android Min SDK Version vs. Target SDK Version

android:minSdkVersion

An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system's API Level is lower than the value specified in this attribute. You should always declare this attribute.

android:targetSdkVersion

An integer designating the API Level that the application is targetting.

With this attribute set, the application says that it is able to run on older versions (down to minSdkVersion), but was explicitly tested to work with the version specified here. Specifying this target version allows the platform to disable compatibility settings that are not required for the target version (which may otherwise be turned on in order to maintain forward-compatibility) or enable newer features that are not available to older applications. This does not mean that you can program different features for different versions of the platform—it simply informs the platform that you have tested against the target version and the platform should not perform any extra work to maintain forward-compatibility with the target version.

For more information refer this URL:

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

Should I change both the target SDK and compile SDK to support higher versions?

It's expected that your app will be forward compatible if you don't update your compileSdkVersion. In other words, it's expected to run/ behave the same way on all the versions supported by your minSDKVersion.

For instance, if your minSDKVersion is API 19 your app will run on Android 4.4, Android 8, Android 9 and it's expected to run on Android 10.

Updating your compileSdkVersion it's a good approach to follow because each new version have another year of development on it - it's expected to be more stable and with newer API's/ functionalities that you can use. Sometimes, doing so, means that you'll have to change some of your behaviours (for more information see here on the official documentation).

If you're looking to difference between compileSdkVersion and targetSdkVersion - you can find a really good answer on another StackOverflow thread.

Briefly:

  • compileSdkVersion

The compileSdkVersion is the version of the API the app is compiled against.

  • targetSdkVersion

    The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify.

Is it better to have min, target and compile SDK set to equal version?

So when a user with KitKat Android opens my app, it should crash
because of Material Design, right? So why is the compiler not
complaining about this and let it pass?

Because the library is backward compatible and so it will not crash. The compiler will complain otherwise.

Is better to have all three pointing to the minimum version that I
want to support?

Depends on your requirement, but in my opinion it is better to have a min sdk to target maximum users.

What is difference between compileSdk and compileSdkVersion in android studio gradle script when using jetpack compose

With the new Android Gradle Plugin 7.0.0 (currently 7.0.0-alpha14) you can use:

  • minSdk instead of minSdkVersion
  • targetSdk instead of targetSdkVersion
  • compileSdk instead of compileSdkVersion

These attributes work with an Int and you can use them with something like:

//minSdkVersion 21
//targetSdkVersion 30
minSdk 21
targetSdk 30

If you want to use a preview version you have to use:

  • minSdkPreview
  • targetSdkPreview
  • compileSdkPreview

These attributes work with a String and setting these values will override previous values of minSdk/targetSdk/compileSdk.

About the String format of the preview versions currently (7.0.0-alpha14) it is not clear. Maybe it will change with 7.0.0-beta01 (you can check this commit) and it should be:

compileSdkPreview = "S"

What should I set for compileSdkVersion, minSdkVersion, and targetSdkVersion?

I set the compileSdkVersion to be 23 which is the latest right now, will older device be able to run it?

Yes. compileSdkVersion on its own has nothing to do with what devices can and cannot run your app. Usually, you set this to be the latest version of the Android SDK.

How do I exactly know what should my minSdkVersion be in order to make sure that phone running lower api or version be unable to access it?

Frequently, the development tools will warn you on the fly when you try using something that is newer than your minSdkVersion. You can run a full Lint check to reconfirm periodically.

How should I set my targetSdk?

In the absence of any particular reason to choose something else, I usually pick the latest or next-to-latest value at the time I create my project (e.g., 22 or 23 now). targetSdkVersion helps with backwards compatibility, and usually my description is "it's the version of Android that you were thinking of at the time you were writing the code".



Related Topics



Leave a reply



Submit