1

I am a beginner.

Whenever I write code, I get confused.

It is when the compiler issues warnings about the API level (SDK version), either in XML code or in Java code.

In my gradle, the current minSdkVersion is 19. Originally it was around 16.

When I first wrote the code, I frequently encountered API level issues. And it seems that the minimum version is too low, so I uploaded the version.

Nevertheless, when writing code, there are many times when a higher API level is requested.

So I am confused.

Maintaining the current version (level 19) Should we handle issues according to the API level? (I don't know how to set it up. Especially in xml)

Or should I just upgrade the version to level 21? (Currently, the api level issue encountered in xml is 21)

What level of level is better to set the minimum level?

Since I am a beginner, I am not sure how much to set the api version.

ybybyb
  • 1,385
  • 1
  • 12
  • 33

2 Answers2

2

I'm not going to tell you which version you should use, instead, I'll explain that certain code and features are only available on newer devices (higher API levels). If you plan to maintain older devices, you'll have to plan around this and not use those features which aren't available at lower versions.

Sure, android does have support for this, you can check API levels in code or make use of specific folders to target specific Api levels but, the older the api you support, the more devices your app will run on and that comes at the cost of having to maintain those olders devices too.

Your choice really, either update your minimum version to support older devices and maintain their code, or increase it, which will remove support to older devices.

if you're going to set it to 21, will this make development easier ? Probably, as more functions will become available to you. Your app won't be usable to people who are making use of android below api 21, but realistically 90% of users will still be able to run your app.


Personal answer, I don't develop for anything under api 23 unless someone requests it


enter image description here

This is the distribution graph*, showing how many users are available when making use of a specific api version

I'm not sure how updated this graph is, but you can find it in android studio when making a new project

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51
  • okay. What your answer means is that I have to make a choice. Whether to use the latest features(?) by `lowering the API level` for more users or by `raising the API level`. Is that right? But more importantly, even if I raise the API level, most users can still use the functions I created. Does this mean? – ybybyb Feb 26 '21 at 18:49
  • 1
    yes, that's what it comes down to. if you raise it to 21/23 you'll still have access to a really wide variety of users and development becomes a bit easier (newer and more functions available) but you'll lose out on a few devices – a_local_nobody Feb 26 '21 at 18:51
  • Thank you so much. Thanks to this, I have decided what to do. After listening to your answers, I decided to raise the api level to `24`. Thank you very much. – ybybyb Feb 26 '21 at 18:54
  • 1
    check my update for more info, there's a graph – a_local_nobody Feb 26 '21 at 18:54
  • According to your graph, even if I upgrade the `api level to 24`, `73.7%` of users are still available? – ybybyb Feb 26 '21 at 18:57
  • 1
    yes. but i honestly think this graph might be outdated a bit, meaning that the percentage will probably be _higher_ not lower – a_local_nobody Feb 26 '21 at 18:57
  • Okay, I'll think about that part properly. Thank you :) – ybybyb Feb 26 '21 at 19:00
2

The API level is a code for the android version.

So the min API level is just the android version, a user of an app needs at least to use it.

If you use a higher API level, there are more features available but a lower API level makes the app accessable for more users.

How you can handle issues is to difference between API levels, e.g. you might say "if the API level is lower than 23, use this view, else use that one" to optimize your app for older and newer devices, but I would not do that in the beginning, because it is hard to test.

Every person I know has at least Android 7 (API-level 24) so don't worry about upgrading to level 21!

Cactusroot
  • 1,019
  • 3
  • 16
  • 1
    `Every person I know has at least Android 7 (API-level 24)` as far as i can remember, google said they won't be supporting anything below api 23 anymore and that was some time ago, at this point it could even be higher than this – a_local_nobody Feb 26 '21 at 18:33
  • So, is the advantage of using a lower API level that you have a wider range of users? The downside is that the code level should be prepared for users with low API level? – ybybyb Feb 26 '21 at 18:45
  • @ybybyb Yes that's correct. – Oke Uwechue Jul 11 '23 at 23:33