First, there is a difference between targetSdkVersion
and compileSdkVersion
.
compileSdkVersion
The compileSdkVersion
gives your app access to the newest APIs, styles and themes. You will have a compilation error if you try to use an API introduced in a more recent Android version than compileSdkVersion
.
targetSdkVersion
targetSdkVersion
indicates which API version your app has been tested against.
Targeting an older version enables compatibility behaviours, to make sure the app continues to work the same way.
Updating the targetSdkVersion
to a newer version may introduce subtle behaviour changes, so make sure your know the new APIs and test the app properly if you do that. For example: calling AlarmManager.set()
when targeting API < 19 will schedule the alarm at the exact time, because that's how it used to work before. Calling the same method while targeting API 19+ will allow the system to adjust the alarm delivery time by a few minutes to save battery life, and if you want the exact time behaviour you need to call the new method AlarmManager.setExact()
.
The compileSdkVersion
must always be equal or higher than the targetSdkVersion
.