Get Your Literacy rate Higher with this Android Article.
Gaurav Sharma
Top 1% Leaders @Flexi Roundtables | GCC Enabler & Ex-Accenture | 65+ Unicorns ?? | Building communities for market, team, and brand value ???? | 400k+ Tribe on Linkedin and with Highest engagement in Industry ??
- What does API Level mean?
- How to use compileSdkVersion, minSdkVersion or targetSdkVersion?
This is the must question should be asked by clients to company.
Introduction:
I always guide my android team to follow below link for latest updates on Android:
https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
There are 4 types of SDK Version:
minSdkVersion
Wonder why some apps are not on search result of Play store apps?
Then Read now below about MinSDK and impact:
It cannot be installed in any normal way on a system with lower API level, this includes command line via adb, manual installation via system UI (installation from unknown source), installation from IDE or gradle scripts and Google Play Store. In the last case app won’t be even shown in search results in Play Store app. In opened app page in store, installation option will be unavailable.
maxSdkVersion
maxSdkVersion which usage not recommended is a partial opposite of minSdkVersion. Using this attribute is almost always not needed since Android API is (almost always) backwards compatible. If this attribute is not defined there is no maximum API level restriction.
targetSdkVersion
It is meaningful only when API level at runtime is higher than targetSdkVersion, in such case some additional compatibility behaviors can be turned on. One of the the drastic example which every other android developer know was introducing JS Interface annotation in API level 17. Starting from it annotation is mandatory and non annotated methods will not work. Developers working before API level 17 was released could not know about that, so apps targeting API level lower than 17 will work without that annotation even on systems with higher API levels. If value is not defined then it will default to minSdkVersion. Recommended way is to set it to the highest API on which app has been tested.
compileSdkVersion
compileSdkVersion is the API level which app is compiled against. Its value determines which APIs can be used in app code (using APIs introduced in higher API levels will cause a compilation error). App can run on device with lower API level if code execution paths do not attempt to invoke any unavailable APIs (except constant which will be simply copied into an app). Value should be always set to the highest stable API level, even if app does not use any API from it. This is due to the fact that some API may be deprecated, stop working – invoked method may start doing nothing like WebView.htmlonChildViewAdded(android.view.View, android.view.View), callbacks may stop being called like WebChromeClient#onJsTimeout(). In such cases compiler warning is raised. Only API levels of installed SDK platforms can be used as a values.
From source code to an APK file
Generally, an Android project is composed by the code developers write using Android API (the application module), plus some other libraries/dependencies (.jar, AAR, local modules…etc) and some resources.
The compilation process converts Java/Kotlin code, dependencies include into DEX byte-code and then compressed everything into an APK file along with some resources. At this stage, the implementation of the API is not included in the resulting APK!
Keep in mind it is highly recommended to compile against the latest API Level and try to have targetSdkVersion == compileSdkVersion.