应用内购买V3项目您请求不可用

问题描述:

我知道这个问题无处不在堆栈溢出和有很多答案这个问题,但我无法解决它。我已经尝试了很多答案,但仍然无法解决问题,我知道我在代码中的某处发生了一些愚蠢的错误,任何人都可以帮我找到问题吗?应用内购买V3项目您请求不可用

这里是我的屏幕截图应用内产品: -

enter image description here

内部清单中声明权限: -

<uses-permission android:name="android.permission.INTERNET" /> 
 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
 
    <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
 
    <uses-permission android:name="com.android.vending.BILLING" /> 
 
    <uses-permission android:name="com.android.vending.CHECK_LICENSE" />

定义SKU为: -

public static final String SKU1 =“gas”; public static final String SKU2 =“infinite_gas”;

购买法: -

public void launchPurchaseFlow(Activity act, String sku, String itemType, 
     int requestCode, OnIabPurchaseFinishedListener listener, 
     String extraData) { 
    checkNotDisposed(); 
    checkSetupDone("launchPurchaseFlow"); 
    flagStartAsync("launchPurchaseFlow"); 
    IabResult result; 

    if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) { 
     IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE, 
       "Subscriptions are not available."); 
     flagEndAsync(); 
     if (listener != null) 
      listener.onIabPurchaseFinished(r, null); 
     return; 
    } 
    try { 
     logDebug("Constructing buy intent for " + sku + ", item type: " 
       + itemType); 
     Bundle buyIntentBundle = mService.getBuyIntent(3, 
       mContext.getPackageName(), sku, itemType, extraData); 
     int response = getResponseCodeFromBundle(buyIntentBundle); 
     if (response != BILLING_RESPONSE_RESULT_OK) { 
      logError("Unable to buy item, Error response: " 
        + getResponseDesc(response)); 
      flagEndAsync(); 
      result = new IabResult(response, "Unable to buy item"); 
      if (listener != null) 
       listener.onIabPurchaseFinished(result, null); 
      return; 
     } 

     PendingIntent pendingIntent = buyIntentBundle 
       .getParcelable(RESPONSE_BUY_INTENT); 
     logDebug("Launching buy intent for " + sku + ". Request code: " 
       + requestCode); 
     mRequestCode = requestCode; 
     mPurchaseListener = listener; 
     mPurchasingItemType = itemType; 
     act.startIntentSenderForResult(pendingIntent.getIntentSender(), 
       requestCode, new Intent(), Integer.valueOf(0), 
       Integer.valueOf(0), Integer.valueOf(0)); 
    } catch (SendIntentException e) { 
     logError("SendIntentException while launching purchase flow for sku " 
       + sku); 
     e.printStackTrace(); 
     flagEndAsync(); 

     result = new IabResult(IABHELPER_SEND_INTENT_FAILED, 
       "Failed to send intent."); 
     if (listener != null) 
      listener.onIabPurchaseFinished(result, null); 
    } catch (RemoteException e) { 
     logError("RemoteException while launching purchase flow for sku " 
       + sku); 
     e.printStackTrace(); 
     flagEndAsync(); 

     result = new IabResult(IABHELPER_REMOTE_EXCEPTION, 
       "Remote exception while starting purchase flow"); 
     if (listener != null) 
      listener.onIabPurchaseFinished(result, null); 
    } 
} 

绑定服务意向: -

Intent serviceIntent = new Intent(
       "com.android.vending.billing.InAppBillingService.BIND"); 
     serviceIntent.setPackage("com.android.vending"); 
     if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0) 
       .isEmpty()) { 
      // service available to handle that Intent 
      mContext.bindService(serviceIntent, mServiceConn, 
        Context.BIND_AUTO_CREATE); 

食用方法: -

void consume(Purchase itemInfo) throws IabException { 
     checkNotDisposed(); 
     checkSetupDone("consume"); 

     if (!itemInfo.mItemType.equals(ITEM_TYPE_INAPP)) { 
      throw new IabException(IABHELPER_INVALID_CONSUMPTION, 
        "Items of type '" + itemInfo.mItemType 
          + "' can't be consumed."); 
     } 

     try { 
      String token = itemInfo.getToken(); 
      String sku = itemInfo.getSku(); 
      if (token == null || token.equals("")) { 
       logError("Can't consume " + sku + ". No token."); 
       throw new IabException(IABHELPER_MISSING_TOKEN, 
         "PurchaseInfo is missing token for sku: " + sku + " " 
           + itemInfo); 
      } 

      logDebug("Consuming sku: " + sku + ", token: " + token); 
      int response = mService.consumePurchase(3, 
        mContext.getPackageName(), token); 
      if (response == BILLING_RESPONSE_RESULT_OK) { 
       logDebug("Successfully consumed sku: " + sku); 
      } else { 
       logDebug("Error consuming consuming sku " + sku + ". " 
         + getResponseDesc(response)); 
       throw new IabException(response, "Error consuming sku " + sku); 
      } 
     } catch (RemoteException e) { 
      throw new IabException(IABHELPER_REMOTE_EXCEPTION, 
        "Remote exception while consuming. PurchaseInfo: " 
          + itemInfo, e); 
     } 
    } 

错误而购买: -

enter image description here

注意: - Alpha测试阶段的应用程序已发布。 我需要从某处批准我的测试人员帐户吗?

这里是整个过程中,我做的事: -

  1. 上传与发布的APK签署认证,以开发 控制台。 我已将我的apk发布到Alpha通道。 我已将我的产品ID列入开发者控制台。 我已经激活了我的产品ID,并在开发者控制台上将其标记为活动。 我已经在开发人员控制台中列出了测试帐户。 我已经安装了与我上传到开发者控制台相同的apk。 设备使用测试帐户而不是开发者帐户登录。 我在我的应用程序中使用的Id与我在控制台上列出的每个logcat消息相同。

任何帮助,将不胜感激提前

感谢。

+0

我有得到2天与您的问题相同类型... PLZ帮助.....谢谢你 –

是的,我解决了这个问题,我用这最后的,非常重要的一步丢失: -

打开选择在与测试帐号的URL,然后点击“成为测试仪”