支持多屏 - 使用 <compatible-screens>

Supporting Multiple Screens - usage of <compatible-screens>

我很难理解如何让我的应用在某些设备上可用但排除其他设备。我有 Acer Iconia One 7 B1。屏幕 7",800x1280 像素和 216 ppi 密度。在我的应用程序首次发布时,Google Play 说它与我的平板电脑不兼容。这是我一开始的清单:

<compatible-screens>
        <!-- all normal size screens -->
        <screen android:screenDensity="mdpi" android:screenSize="normal" />
        <screen android:screenDensity="hdpi"  android:screenSize="normal" />
        <screen android:screenDensity="xhdpi"  android:screenSize="normal"/>
        <screen android:screenDensity="xxhdpi" android:screenSize="normal"/>
        <!-- mdpi and hdpi large size screens -->
        <screen android:screenDensity="mdpi"  android:screenSize="large" />
        <screen android:screenDensity="hdpi"  android:screenSize="large" />
        <!-- mdpi x-large size screens -->
        <screen android:screenDensity="mdpi"  android:screenSize="xlarge" />
    </compatible-screens>

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="25"
        />

经过研究,我发现我的平板电脑有 tvdpi 密度,所以我在清单中添加了几行以包含所有正常尺寸的屏幕:

<screen   android:screenSize="normal"  android:screenDensity="213"/>
<screen   android:screenSize="normal"  android:screenDensity="420"/>
<screen   android:screenSize="normal"  android:screenDensity="560"/>
<screen   android:screenSize="normal"  android:screenDensity="xxxhdpi"/>
<!-- to exclude TVs -->
      <uses-feature android:name="android.hardware.touchscreen"   
                    android:required="true"/>

当我上传我的应用程序的第 2 版时,Google 控制台向我显示了一个警告,尽管我添加了更多兼容的屏幕,但 更新后的 apk 支持的设备少于第 1 版!! ! 请帮助我了解我做错了什么?基本上,无论密度如何,我都需要支持所有可能的正常屏幕尺寸;大 MDPI 和 HDPI 以及超大 MDPI。

我猜你排除电视的代码是罪魁祸首,电视应用只能通过使用 Leanback Intent 库(默认情况下禁用)来支持。

通过强制使用触摸屏,您只淘汰了少数设备(包括 运行 phone 版本 android 的廉价 android 电视盒)

听起来你根本不应该使用 <compatible-screens>

来自文档:

Caution: Normally, you should not use this manifest element. Using this element can dramatically reduce the potential user base for your application, by not allowing users to install your application if they have a device with a screen configuration that you have not listed. You should use it only as a last resort, when the application absolutely does not work with specific screen configurations.

你说"I need to support all possible normal screen sizes no matter the density"。如果这意味着您必须 排除 small 屏幕尺寸,则可以改用 <supports-screens> 元素。像

<supports-screens
    android:smallScreens="false"/>

在研究了两天之后(真可惜我花了这么长时间),我查看了 Android Studio 中的 AVD 管理器,发现 Nexus 7 与我的规格相同Acer Iconia,被认为是大的,而不是普通的。 一旦我改变了

<screen   android:screenSize="normal"  android:screenDensity="213"/>

至:

<screen   android:screenSize="large"  android:screenDensity="213"/>

并将新的 APK 上传到 Play 商店,我的平板电脑终于与该应用程序兼容了。我希望有一天,当有人无法弄清楚为什么他们的 tvdpi 平板电脑被认为与他们的应用程序不兼容时,这对他们有所帮助。