by Osiris · 8y ago · 0 comments
Android Oreo is only running on 1.1% of devices [1]. Will targeting the newest API prevent the app from being available for in the market for devices running Nougat or earlier or does it just limit the functionality?
[1] https://www.androidauthority.com/android-version-distributio...
For instance, Android can't enforce dynamic permissions on older Apps not designed for this, and people have been exploiting this by keeping the target API level low.
A good concrete example is the switch from making users agree to permissions when they install an app to runtime permissions. In the new style, the app is responsible for bringing up dialogs to ask for permissions. In the old style, the system does it when you install. So how does the system know whether your app knows how to ask? By setting targetSdkVersion to 23, you tell the system, "It's safe to assume I know about this new API I'm required to implement." But that doesn't preclude your app from running on older systems, where things behave just like they always did.
Also that dashboard can be misleading - if you check any english app you'll probably have more like 40% of 7.0 and 10-20% of Oreo deployed.
As for targeting - targetSdk determines against which version of Android APIs are you linking against (the stub .jar) and by extension which compatibility shims will new Android versions use. If you listen to a linter and properly guard usage of APIs added in newest Androids then the app will run well on old Android versions as well.
The main benefit of this change is security - if your app doesn't target Android 6.0 or newer, it's exempt from the new permissions system introduced in 6.0.A lot of companies, including large ones like Facebook and Snap, deliberately refused to support new Android features so they could access hardware and collect data without explicitly asking for permission. This change forces them to start using those new APIs.
Targeting Oreo means telling the OS to disable backwards-compatibility behaviour which would otherwise apply.