3

I have read the Android documentation here and this similar question here, but have a question on the real life implications of this version.

My app had a targetSdkVersion of 25 while in development, and I was trying it out with a SDK level 27 (Android 8.1) phone with no issues.

My question is specifically about broadcast receivers. Prior SDK 26, you can register for broadcasts in manifest file and you will receive all the broadcasts you registered for. But 26 changed that to severely limit this mechanism that you cannot receive any implicit broadcasts, like Wifi connection changes. And instead they recommend using JobScheduler, with a minimum period of 15 minutes. This would absolutely not work for my app.

Now what I want to understand is, what are the implications of releasing my app with a target SDK version of 25, given that I do not use any features of latest SDK (27)?

Would there be any restrictions for a phone running SDK > 25 to use my app?

Thank you.

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
madu
  • 5,232
  • 14
  • 56
  • 96

2 Answers2

2

The scenario you are mentioning is know as forward compatibility in Android. You can think it in other way as well, you app is already in Google Play Store and user updated his device software. In such case, Android/Google strongly focus on that existing apps built against prior SDKs should not break when the user updates to a new version of Android.

If any API of API level 25 you are using in your app is not deprecated in API level 27, there is no issue. It is completely fine to set targetSdkVersion : 25.

But it is always recommended to compile your app with latest available SDK so that you can minimize the risk of crash/warnings of your code with respect to latest SDK.

So basically what you should follow is:

minSdkVersion <= targetSdkVersion <= compileSdkVersion

Hope this will help you.

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
1

When you run your application on a version of on Android that have a higher version than the targetSdkVersion specified this may lead to some issues.

For example, if the targetSdkVersion is less than 14, your app may get an option button in the UI.

Thus, to have the compatibility of the android version you better need to set the compileSdkVersion and targetSdkVersion the same.