1

I am just about to release an application (To friends and family at least). My project API levels are:

minSdkVersion 19
targetSdkVersion 23

I hear this question a lot when people are about to start their endeavour;

What API level should I target?

I am obviously way past that - Using 19 as minSdkVersion will work for most of my target audience.

What I am wondering is this; I am unsure if the code I have written actually needs SDK level 19. I am thinking I could possibly reach a larger audience without modifying anything other than minSdkVersion.

I am however unsure about how to test this. Can I simply try lowering it until Gradle throws build errors? Is it guaranteed to work, if the app builds? I can't seem to find this information anywhere.

Treeline
  • 475
  • 1
  • 8
  • 23

1 Answers1

2

Well, that completely depends upon what features are you planning to have in your app. What are the bare features that you must have (make an exhaustive list) to make your app do stuff that it is supposed to do.

Every SDK version is released with a few additional features. Some of them come with a support library, which make the feature work even in some early API levels.

How to test how low I can go?

Well, atleast you cannot go low beyond what all your dependencies allow you to go. Suppose you are using a few libraries that require minimum 11, 14 and 17, then you cannot go below 17. That's one cap. And here you need to take care of the support libraries. For example, fragments were released with 11, but using support libraries, you can use it in gingerbread and froyo. So, cap-value lowered further!

And how do I get this cap-value?

Ideally, before starting the development. Write down what features you need and what libraries/classes you will need to implement them. Find the minimum api level that supports them. And there you have it. Now, since you're already done with the app and you don't really plan to release it for as many devices as you can, keep lowering the gradle is the best time-efficient thing you can do.

Akeshwar Jha
  • 4,516
  • 8
  • 52
  • 91
  • Then I have my answer; It is safe to keep lowering the SDK level until Gradle produces errors. I was very suspicious about it because I could go as low as 8 before getting the error `uses-sdk:minSdkVersion 8 cannot be smaller than version 9 declared in library [com.google.android.gms:play-services-location:8.4.0]`. From 9 to 19 is 10 API levels after all. – Treeline Apr 30 '16 at 15:21
  • It should work. Still, it'll be wise to test the app on an API level 9 device first. – Akeshwar Jha Apr 30 '16 at 15:26
  • So just because Gradle accepts some lower API level, is not a guarantee that it works the same? – Treeline Apr 30 '16 at 15:28
  • 1
    Sometimes, gradle runs clean, but the app crashes while running it on a device. So, an error-free gradle is not always a guarantee to a working app. For example, check this question out: http://stackoverflow.com/questions/32328806/app-crashing-on-android-api-less-than-5-0lollipop I had a similar problem. My minimum API level was 17, my gradle was doing fine, but when I ran the app on emulator, it was constantly getting crashed for kitkat and below devices. However, the app was running smoothly for lollipop onwards. – Akeshwar Jha May 01 '16 at 06:19