Search code examples
androidsdktarget-sdk

Should I change both the target SDK and compile SDK to support higher versions?


I would like my app to run on Android 9. Currently it both targets and compiles to SDK 26. When update my target and compile version from 26 to 28, nothing much seems to change. It runs the same on my own phone (22) and emulator at 25, but it also now runs on 28 as well. I didn't change a single line of code other than the target and compile versions.

Did my app just not use anything that needed to be changed? It is a pretty straightforward SQLite app which doesn't even use internet.

If I want my app to run on android 9, should I target to 28, compile to 28, or both?


Solution

  • It's expected that your app will be forward compatible if you don't update your compileSdkVersion. In other words, it's expected to run/ behave the same way on all the versions supported by your minSDKVersion.

    For instance, if your minSDKVersion is API 19 your app will run on Android 4.4, Android 8, Android 9 and it's expected to run on Android 10.

    Updating your compileSdkVersion it's a good approach to follow because each new version have another year of development on it - it's expected to be more stable and with newer API's/ functionalities that you can use. Sometimes, doing so, means that you'll have to change some of your behaviours (for more information see here on the official documentation).

    If you're looking to difference between compileSdkVersion and targetSdkVersion - you can find a really good answer on another StackOverflow thread.

    Briefly:

    • compileSdkVersion

    The compileSdkVersion is the version of the API the app is compiled against.

    • targetSdkVersion

      The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify.