Search code examples
androidandroid-studiosdkandroid-5.0-lollipopandroid-6.0-marshmallow

Targeting lower SDK version in android


am making an app which stores and retrieves images from the user's storage directory. My app crashes on Marshmallow devices whenever any file related action is performed.

When I built my app I set the targetSdkVersion to 23 in gradle build and now the app is completed and works fine on all pre-Marshmallow devices.

I have noticed if I set the targetSdkVersion to 21 the app works fine on Marshmallow too, so is it okay to set it to 21 or it has any negative consequences ??


Solution

  • Using targetSdkVersion 23 you have to manage the runtime permissions for all devices with api 23+.

    Using targetSdkVersion 22 or lower you don't have to manage the runtime permissions but pay attention because in all devices with api 23+ users can revoke permissions from any app at any time, even if the app targets a lower API level.