我怎样才能确保我的应用程序不能安装在 Marshmallow 上

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

在 android gradle 构建文件中我有以下闭包:

android {
compileSdkVersion 21
buildToolsVersion "23.0.1"

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

我不希望我的应用 运行 在 Marshmallow 上。我的 targetSdkVersion 是 21,Marmallow 是 23。想象一下我有一个 phone 是 Marshmallow,如果我去 Play 商店,我的应用程序会出现在列表中吗?

我的第二个问题是如何阻止我的应用出现在棉花糖设备的 google Play 商店中?

So imagine i have a phone that is Marshmallow, if i go to the play store will my app appear in the listing ?

是的。

how would i stop my app from appearing in google play store for marshmallow devices?

欢迎您在清单的 <uses-sdk> 元素中尝试 android:maxSdkVersion,因为 the current documentation 建议 Play 商店将其用作过滤器,尽管这是有代价的将应用程序升级到 Android 6.0.

的用户

不是回答原始问题,而是回答问题的原因。

我不确定你必须这样做。

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

您仍然可以使用 HTTP 客户端。 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'
}

我尝试在 Android 6.0 上安装使用 HTTP 客户端的旧应用程序。它们仍然可以工作,没有 build.gradle 中的依赖性,甚至不需要重新编译。


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

应用程序不会中断。如果您不在 Marshmallow(targetSdkVersion 23 或更高版本)下编译您的应用程序,那么它将在 "legacy" 模式下运行:安装前将请求权限。除了一个例外:用户仍然可以在设置中关闭权限;我不认为很多用户这样做。


在模拟器或真实设备中试用您的应用。我几乎可以肯定它会在 Marshmallow 下工作。

可能是我认为如果我们将 api 定位到 23

,应用程序运行时权限模型将起作用

注意:本课介绍如何在 API 级别 23 或更高级别的应用程序上实现权限请求,并且 运行 在 运行 Android 的设备上6.0(API 23 级)或更高。如果设备或应用的targetSdkVersion为22或更低,系统会提示用户在安装或更新应用时授予所有危险权限。

link: https://developer.android.com/intl/es/training/permissions/requesting.html

可能是我有什么误会请通知我