0

I have gone through several articles and documentation and SO question to understand difference between minSDK vs targetSDK vs compileSDK already.

E.g. this on Medium : Picking your compileSdkVersion, minSdkVersion, and targetSdkVersion

Which basically summarizes

minSdkVersion <= targetSdkVersion <= compileSdkVersion

But still want to understand what if I set TargetSDK = 22 but Compile SDK =26 what are the pros and cons ?

Points to be considered are -

  1. I want to use RxJava 2, Dagger 2, Android Architecture Components provided with latest support libs, Android Studio 3.0 with Gradle 4.1 etc.
  2. By making Target SDK version to 22 which below Android M , I want to avoid runtime permission dialogs.
  3. Should be able to migrate to Kotlin in future.
  4. minSDK version is and going to remain 15
Nayanesh Gupte
  • 2,735
  • 25
  • 37
  • *Don't ask about... **Requests for lists of things, polls, opinions, discussions*** – Selvin Oct 30 '17 at 10:25
  • 2
    *By making Target SDK version to 22 which below Android M , I want to avoid runtime permission dialogs* that's how bad apps are made – Selvin Oct 30 '17 at 10:25
  • @selvin why? What if i make that decision to keep target sdk =22 but compilesdk =26 and suffer later while developing app ? – Nayanesh Gupte Oct 30 '17 at 10:26
  • @Selvin do you can think snapchat is bad ? they have huge no of downloads but targetSDK version is 22 – Nayanesh Gupte Oct 30 '17 at 10:27
  • The problem is that if users disable permissions from settings, your app will crash. If you use my library, you won't need to bother about runtime-permissions again. https://github.com/nabinbhandari/Android-Permissions – Nabin Bhandari Oct 30 '17 at 10:28
  • @NabinBhandari I'm not scared of writing runtime permissions code , concern is not sowing those dialogs. – Nayanesh Gupte Oct 30 '17 at 10:30
  • Like Selvin said, if you goal is doing that, you are actually using the con of not targeting the last SDK version. And yes, I said con. Runtime permissions have a purpose for the user experience. The only pro is for you, since you will be able to make an app not following the Google guidelines – JMedinilla Oct 30 '17 at 10:32
  • 1
    If you don't want to follow the guidelines from Google, I don't have anything to say about it. – Nabin Bhandari Oct 30 '17 at 10:33
  • OP gave us an article wich clearly says: "updating to target the latest SDK should be a high priority for every app" – JMedinilla Oct 30 '17 at 10:40
  • @NabinBhandari I don't deny it's a bad practice. I want to understand problems which might occur because of it from development perspective. Thanks. – Nayanesh Gupte Oct 30 '17 at 10:49
  • @IntelliJAmiya you have given me same link what I have given in my original question – Nayanesh Gupte Oct 30 '17 at 10:51
  • Well, it's pretty simple. When I download your app, I will revoke the permission anyway because I do not trust an app that I didn't make. Then, when I launch your app, it will crash because you don't ask for them and take them for granted. There is no "development perspective", just a bad app and implementation problem. And API 23 is now the most used one worldwide, so you can expect that almost anyone can revoke your permissions. – JMedinilla Oct 30 '17 at 10:51
  • 1
    @NayaneshGupte You should use same version (Respect to compileSdkVersion) – IntelliJ Amiya Oct 30 '17 at 10:52

2 Answers2

5

Update - Aug 2 2018:

Following is a part of an email sent by Google to the developers.

This is a reminder that starting November 1, 2018, updates to apps and games on Google Play will be required to target Android Oreo (API level 26) or higher. After this date, the Play Console will prevent you from submitting new APKs with a targetSdkVersion less than 26.

Hence it won't be practical to target SDK version 22 from the mentioned date.

Original Answer:

Target SDK 22

Pro:

  • You don't need to write code for runtime permissions. (Only for you, no advantage to users)

Cons:

  • Bad practice and bad UX - Not according to guidelines from Google.
  • App will crash if user revokes permissions from the settings.
  • You will get bad reviews from the users saying "too many permissions" since they will be asked to grant all the permissions before installation.
  • Probably your app will get less priority in organic search.
Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
1

Cons

In addition to the ones already mentioned in other answers, here are some more cons

  • TargetSDK 22 disables some Doze optimizations. This could lead to your app not being as battery optimized as it could be.

Pros

Some of these are very specific to the type of app

  • The Doze mode could actually hinder the app functionality. Real-world example: some type of fitness apps just cannot work reliably when doze mode is enabled (unless you create a foreground service). In such cases, targetSDK = 22 could be more appropriate.
  • Pro for the user: With targetSDK > 22, you are encouraged to use Google Play Services. In addition to it not being available on all devices, it actually blurs which app is actually causing battery drain (now the battery consumption is attributed to "Google Play Services" rather than the actual misbehaving app). So they don't know which app to uninstall. Since we are talking about user experience, setting targetSDK = 22 could be better for the user since you are being honest about the battery drain you are causing.

In general, it is advisable to use the latest targetSDK if at all possible - unless your app just cannot function under the restrictions in the newer SDK versions.

curioustechizen
  • 10,572
  • 10
  • 61
  • 110