问题
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.
回答1:
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"
com/google/android/finsky/utils/DocUtils.java
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;
break;
case 8:
resourceId = R.string.availability_restriction_not_in_group;
break;
case 9:
if (document.getDocumentType() != 1) {
resourceId = R.string.availability_restriction_hardware;
break;
}
resourceId = R.string.availability_restriction_hardware_app;
break;
case 10:
resourceId = R.string.availability_restriction_carrier;
break;
case 11:
resourceId = R.string.availability_restriction_country_or_carrier;
break;
case 12:
resourceId = R.string.availability_restriction_search_level;
break;
case 21:
resourceId = R.string.availability_restriction_for_managed_account;
break;
case 22:
resourceId = R.string.availability_restriction_missing_permission;
break;
}
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
com/google/android/finsky/activities/AppsPermissionsActivity.java
com/google/android/finsky/billing/lightpurchase/OfferResolutionActivity.java
com/google/android/finsky/detailspage/WarningMessageModule.java
com/google/android/finsky/layout/WarningMessageSection.java
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.
来源:https://stackoverflow.com/questions/31920605/unable-to-install-some-apps-from-google-play-on-customized-aosp-item-is-not-ava