I am getting lot of exceptions in crash report for my app in google store. Can somebody hep me what could cause this? I am using android:targetSdkVersion=19
java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user 10131 nor current process has android.permission.READ_PHONE_STATE.
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at com.android.vending.billing.IInAppBillingService$Stub$Proxy.getSkuDetails(IInAppBillingService.java:251)
at com.inapp.util.IabHelper.querySkuDetails(IabHelper.java:920)
at com.inapp.util.IabHelper.queryInventory(IabHelper.java:550)
at com.inapp.util.IabHelper.queryInventory(IabHelper.java:522)
at com.inapp.util.IabHelper$2.run(IabHelper.java:617)
at java.lang.Thread.run(Thread.java:818)
Although Google has confirmed to have shipped the update having the fix, but the following try catch block at least prevents the crash
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
throws RemoteException, JSONException {
logDebug("Querying SKU details.");
ArrayList<String> skuList = new ArrayList<String>();
skuList.addAll(inv.getAllOwnedSkus(itemType));
if (moreSkus != null) {
for (String sku : moreSkus) {
if (!skuList.contains(sku)) {
skuList.add(sku);
}
}
}
if (skuList.size() == 0) {
logDebug("queryPrices: nothing to do because there are no SKUs.");
return BILLING_RESPONSE_RESULT_OK;
}
// NullPointer crash reported through PlayStore forums
if (mService == null) {
return IABHELPER_SERVICE_UNAVAILABLE;
}
Bundle querySkus = new Bundle();
querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
try {
Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);
if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
int response = getResponseCodeFromBundle(skuDetails);
if (response != BILLING_RESPONSE_RESULT_OK) {
logDebug("getSkuDetails() failed: " + getResponseDesc(response));
return response;
}
else {
logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
return IABHELPER_BAD_RESPONSE;
}
}
ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
for (String thisResponse : responseList) {
SkuDetails d = new SkuDetails(itemType, thisResponse);
logDebug("Got sku details: " + d);
inv.addSkuDetails(d);
}
return BILLING_RESPONSE_RESULT_OK;
}
// Security Exception due to missing permissions reported through PlayStore forums
catch (SecurityException e)
{
return IABHELPER_SERVICE_UNAVAILABLE;
}
}
Please note that the only change in the method int querySkuDetails(String itemType, Inventory inv, List moreSkus) is the try catch block of the Security Exception. Rest everything remains same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With