pilcrowpipe pilcrowpipe - 9 months ago 51
Android Question

Unable to install some apps from Google Play on customized AOSP: Item is not available. Reason: 9

I'm getting the following error when trying to install some apps from Google Play:

LibraryUtils.isAvailable: not available restriction=9
DocUtils.getAvailabilityRestrictionResourceId: Item is not available. Reason: 9

I'm running a customized version of AOSP (a customized Android x86 flavor) on x86 hardware. I've researched a lot and there are lots of vague attempts/guesses at answers already on the net but I'm specifically looking for what "Reason 9" refers to. Once I have that, I'm hoping I can come up with a hack in AOSP to avoid the error as when I sideload the same apps they run fine. This is hobby I'm doing so I'm not worried about some possible unintended side effects.

Answer Source

If you pull the Play Store APK from your device you can decompile it. I decompiled the APK and did a simple search for your error message. The error message can be found in the class com.google.android.finsky.utils.DocUtils

$ grep -lr "Item is not available"

Here is the method:

public static int getAvailabilityRestrictionResourceId(Document document) {
    int restriction = document.getAvailabilityRestriction();
    int resourceId = R.string.availability_restriction_generic;
    switch (restriction) {
        case 2:
            resourceId = R.string.availability_restriction_country;
        case 8:
            resourceId = R.string.availability_restriction_not_in_group;
        case 9:
            if (document.getDocumentType() != 1) {
                resourceId = R.string.availability_restriction_hardware;
            resourceId = R.string.availability_restriction_hardware_app;
        case 10:
            resourceId = R.string.availability_restriction_carrier;
        case 11:
            resourceId = R.string.availability_restriction_country_or_carrier;
        case 12:
            resourceId = R.string.availability_restriction_search_level;
        case 21:
            resourceId = R.string.availability_restriction_for_managed_account;
        case 22:
            resourceId = R.string.availability_restriction_missing_permission;
    FinskyLog.d("Item is not available. Reason: " + restriction);
    return resourceId;

In your case, the response has a restriction of 9. This would either get one of two strings. If we decompile the resources of the APK using ApkTool we can see the values of these two strings.

<string name="availability_restriction_hardware">"Your device isn't compatible with this item."</string>
<string name="availability_restriction_hardware_app">"Your device isn't compatible with this version."</string>

The method getAvailabilityRestrictionResourceId(Document document) is invoked in the following classes:

$ grep -lr getAvailabilityRestrictionResourceId | grep -v DocUtils

It would be beneficial if you provide info on when this gets logged.

The problem is still vague. From searching on Google, some people have solved similar problems by changing a system property (most often in /system/build.prop).

Probably not the answer your hoping for, but I hope my research helps out.