Search code examples
androidgoogle-playandroid-6.0-marshmallowtarget-sdk

How can I ensure my app can not be installed on Marshmallow


In android gradle build file I have the following closure:

android {
compileSdkVersion 21
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.mycoolapp"
    minSdkVersion 16
    targetSdkVersion 21
    versionCode 41
    versionName "3.0"
}
}

I do not want my app to run on Marshmallow. My targetSdkVersion is 21 and Marmallow would be 23. So imagine I have a phone that is Marshmallow, if I go to the play store will my app appear in the listing?

My second question is how would I stop my app from appearing in google play store for marshmallow devices?


Solution

  • Answering not to original question, but to reasons of it.

    I'm not sure you have to do it.

    api 23 is asking for runtime permissions. so if i have a device running 23 and since android is backward compatible, what will happen for example if im using apache httpClient which is depreacated in marshmallow

    You still can use HTTP client. From the docs:

    To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

    android {
        useLibrary 'org.apache.http.legacy'
    }
    

    I tried to install my old applications which use HTTP Client on Android 6.0. They still work, without the dependency in build.gradle and even without recompiling.


    or if im not prepared to handle runtime permissions ? wont my app break in this case ?

    App wouldn't break. If you don't compile your app under Marshmallow (targetSdkVersion 23 or higher) then it will work in "legacy" mode: permissions will be requested before installation. With one exception: users still can switch off permissions in settings; I don't think that many users do it.


    Try your app in emulator or real device. I'm almost sure it will work under Marshmallow.