Panich Maxim Panich Maxim - 2 months ago 8
Android Question

<compatible-screens> in Android

Good day, I am trying to restrict screen sizes to only handsets (i.e. not tablets) in google play. After I found this article I added this to my manifest file:

<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
</compatible-screens>


But it appears that now users with 5.5++ inch phones cant install my app. Next I also found this article and picture in it:

enter image description here

My first question - is it possible to restrict screen size by specific inch value, or I can use only tags like small, normal, large and xlarge?

At some point I decided to increase support inch size to 7 by updating manifest like this:

<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
<!-- all large size screens -->
<screen android:screenSize="large" android:screenDensity="ldpi" />
<screen android:screenSize="large" android:screenDensity="mdpi" />
<screen android:screenSize="large" android:screenDensity="hdpi" />
<screen android:screenSize="large" android:screenDensity="xhdpi" />
</compatible-screens>


But users with 5.5 inch phones and even with 5.2 inch still cant install app.

So my second question - what I am doing wrong or don't understand?

I honestly read all similar questions on stackoverflow and articles in android documentation and didn't find proper answer. Thx.

Answer

It looks like you are attempting to restrict screen sizes to only handsets, and not tablets. It is difficult to discern from your question, but either way I think I can clear up the confusion.

When you declare <compatible-screens> in your manifest you must declare every screen configuration that you would like your app to be compatible with:

You must declare each one of these; any combination of size and density that you do not specify is considered a screen configuration with which your application is not compatible.

I suspect the 5.5+ inch phones you mention have a higher density than xhdpi; such as xxhdpi or xxxhdpi. These densities are omitted from the documentation (either because the documentation is outdated or otherwise incomplete) but are still relevant; they are documented on the <compatible-screens> page.

Therefore if you want your app to be compatible with higher density devices, you must include those densities in your <compatible-screens> element. But an easier method would be to use the <supports-screens> element instead. As per the documentation, the <supports-screens> element does not take density into account:

Note: Although you can also use the <compatible-screens> element for the reverse scenario (when your application is not compatible with smaller screens), it's easier if you instead use the <supports-screens> as discussed in the next section, because it doesn't require you to specify each screen density your application supports.

With this you can just specify the following in your manifest:

<supports-screens android:smallScreens="true"
                  android:normalScreens="true"
                  android:largeScreens="false"
                  android:xlargeScreens="false"
                  android:largestWidthLimitDp="840"/>

The largestWidthLimitDp attribute should not be necessary, but 840dp seems like a good limit for handsets based on the Material Design documentation for density breakpoints.

Otherwise, you can still use the <compatible-screens> tag if you would like more fine-tuned control over which devices your app is compatible with:

<compatible-screens>
    <!-- all small size screens -->
    <screen android:screenSize="small" android:screenDensity="ldpi" />
    <screen android:screenSize="small" android:screenDensity="mdpi" />
    <screen android:screenSize="small" android:screenDensity="hdpi" />
    <screen android:screenSize="small" android:screenDensity="xhdpi" />
    <screen android:screenSize="small" android:screenDensity="xxhdpi" />
    <screen android:screenSize="small" android:screenDensity="xxxhdpi" />
    <!-- all normal size screens -->
    <screen android:screenSize="normal" android:screenDensity="ldpi" />
    <screen android:screenSize="normal" android:screenDensity="mdpi" />
    <screen android:screenSize="normal" android:screenDensity="hdpi" />
    <screen android:screenSize="normal" android:screenDensity="xhdpi" />
    <screen android:screenSize="normal" android:screenDensity="xxhdpi" />
    <screen android:screenSize="normal" android:screenDensity="xxxhdpi" />
</compatible-screens>
Comments