11

Je reçois beaucoup d'exceptions dans le rapport de plantage pour mon application dans google store. Quelqu'un peut-il me prévenir de ce qui pourrait causer cela? J'utilise Android: targetSdkVersion = 19Facturation InApp: java.lang.SecurityException Requires READ_PHONE_STATE

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) 
+0

C'est probablement ce que l'exception dit, votre manque l'autorisation de READ_PHONE_STATE –

+2

je pense qu'il est plus probable qu'il est dans le manifeste, mais il n'a pas été accordé sur les appareils Guimauve. https://developer.android.com/training/permissions/requesting.html – DeeV

+0

Gardez à l'esprit que même si vous ciblez Api-19, les utilisateurs de Marshmallow peuvent révoquer manuellement l'autorisation après l'installation. –

Répondre

-7

Ajouter l'autorisation appropriée dans votre AndroidManifest.xml

<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
2

Bien que Google a confirmé avoir envoyé la mise à jour ayant le correctif, mais le bloc catch try suivant au moins empêche l'accident

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; 
       } 
} 

S'il vous plaît noter que le seul changement dans la méthode querySkuDetails int (Str La commande itemType, Inventory inv, List moreSkus) est le bloc try catch de l'exception de sécurité. Repos tout reste pareil.