• Android: xxhdpi screenDensity Setting in AndroidManifest.xml

    Android res Folder StructureGoogle discourages the use of the <compatible-screens> option in the AndroidManifest XML file, but there are certain occasions when it is very useful. For example, in a picture gallery-based app, it is desirable to split the application into multiple apk files so that someone with a low resolution handset does not need to download a bloated apk filled with xhdpi images. In these cases, it is necessary to use the <compatible-screens> option to restrict which each of the multiple apks apply to which specific screens.

    Having built an app which has been split in this manner, I found that the Galaxy S4 would not allow the application to be installed. This is because the screen pixel density is xxhdpi, which had not originally been specified in any AndroidManifest.xml belonging to any of my apks. At the time of writing, xxhdpi is still not a supported option on the Android developer website:

    android:screenDensity=["ldpi" | "mdpi" | "hdpi" | "xhdpi"]

    Trying to put xxhdpi as the screenDensity, for example:

    <compatible-screens>
        <screen android:screenSize="small" android:screenDensity="xxhdpi" />
        <screen android:screenSize="normal" android:screenDensity="xxhdpi" />
        <screen android:screenSize="large" android:screenDensity="xxhdpi" />
        <screen android:screenSize="xlarge" android:screenDensity="xxhdpi" />
    </compatible-screens>

    results in the following error message:

    error: Error: String types not allowed (at 'screenDensity' with value 'xxhdpi').

    To get around this problem (if you have no option but to use the <compatible-screens> option with a screenDensity parameter), the following configuration will compile and will enable the app to run on xxhdpi screens:

    <compatible-screens>
        <screen android:screenSize="small" android:screenDensity="480" />
        <screen android:screenSize="normal" android:screenDensity="480" />
        <screen android:screenSize="large" android:screenDensity="480" />
        <screen android:screenSize="xlarge" android:screenDensity="480" />
    </compatible-screens>

    Don’t forger to create the necessary res/drawable-xxhdpi folder.

One Responseso far.

  1. Napster says:

    This post was really useful. I was on the verge to the release, and it really helped me. Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human: *