Android的账单 - 项目未找到 [英] Android billing - item not found

查看:280
本文介绍了Android的账单 - 项目未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个订购产品,当人们试图购买它,他们从我的应用程序在App Store点击,他们得到一个错误找不到项目

但项目实况显示在我的开发者控制台。

下面是我把它叫做:

下面是这个方法的onActivityResult():

 保护无效的onActivityResult(INT申请code,INT结果code,意图数据)
{
    sendEmail(TAG的onActivityResult(+请求code +,+结果code +,+数据

结果是:

 的onActivityResult(10001,0,意向{(有临时演员)}

和onIabPurchaseFinished

  IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener =新IabHelper.OnIabPurchaseFinishedListener()
{
    公共无效onIabPurchaseFinished(IabResult结果,购购)
    {
        sendEmail(TAG,购买完成:+结果+,购买+购买);

似乎从来没有得到执行。

 公共无效onUpgradeAppButtonClicked()
{
    sendEmail(TAG,购买按钮点击,推出升级SKU采购流程:+ SKU_SUBSCRIPTION +和RC_REQUEST:+ RC_REQUEST);
    // setWaitScreen(真);
    mHelper.launchPurchaseFlow(这一点,SKU_SUBSCRIPTION,RC_REQUEST,mPurchaseFinishedListener);
}

造成这样的:

采购单击按钮;推出升级的购买流程。 SKU:my_sku和RC_REQUEST:10001

会有人知道为什么出错?难道说这发生在一些较老的手机呢?

另外,如果有人可以尝试在手机上,也许,这将帮助,因为我只有一个手机:)这个测试是链接到应用程序:
https://play.google.com/store/apps /details?id=com.problemio&hl=en

和去结算是主屏幕最底部按钮。

编辑:

我知道有时候是需要时间的应用内商品真正去住在Android系统,但它说,住在我的dev的控制台:)

编辑:

在我IABHelper.java我有这样的:

  / **
 *与调用{@link #launchPurchaseFlow(活动,字符串,INT,OnIabPurchaseFinishedListener,字符串)}
 *使用null作为extraData。
 * /
公共无效launchPurchaseFlow(活动行为,字符串SKU,INT请求code,OnIabPurchaseFinishedListener听众){
    launchPurchaseFlow(ACT,SKU,请求code,监听器,);
}

,然后这样的:

  / **
 *启动一个应用程序内购买的UI流程。调用此方法来启动一个应用程序内购买,
 *这将涉及造就了谷歌Play屏幕。调用活动将暂停,而
 *用户与谷歌播放相互作用,其结果将通过该活动的递送
 * {@link android.app.Activity#}的onActivityResult方法,在这一点,你必须调用
 *此对象的{@link #handleActivityResult}方法来继续购买流程。这种方法
 *必须从活动的UI线程调用。
 *
 * @Param行动调用的活动。
 *购买该项目的@param SKU的SKU。
 * @参数要求code的请求code(从其他的响应区分 -
 *在{@link android.app.Activity#startActivityForResult})。
 * @参数监听器监听通知在购买过程完成
 * @参数extraData额外的数据(开发有效载荷),将与购买数据返回
 *购买时完成。这个额外的数据将被永久绑定到购买
 *当购买查询总是会返回。
 * /
公共无效launchPurchaseFlow(活动行为,字符串SKU,INT请求code,OnIabPurchaseFinishedListener监听器,串extraData){
    checkSetupDone(launchPurchaseFlow);
    flagStartAsync(launchPurchaseFlow);
    IabResult结果;    尝试{
        logDebug(买入建设为目的+ SKU);
        捆绑buyIntentBundle = mService.getBuyIntent(3 mContext.getPackageName(),SKU,ITEM_TYPE_INAPP,extraData);
        INT响应= GETRESPONSE codeFromBundle(buyIntentBundle);
        如果(响应!= BILLING_RESPONSE_RESULT_OK){
            LOGERROR(无法购买物品,错误的回应:+ getResponseDesc(响应));            结果=新IabResult(响应,无法购买项目);
            如果(!监听= NULL)listener.onIabPurchaseFinished(结果,NULL);
        }        的PendingIntent的PendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        logDebug(启动购买意向为+ SKU +请求code:+请求code);
        mRequest code =请求code;
        mPurchaseListener =侦听器;
        act.startIntentSenderForResult(pendingIntent.getIntentSender(),
                                       要求code,新意图()
                                       Integer.valueOf(0),Integer.valueOf(0),
                                       Integer.valueOf(0));
    }
    赶上(SendIntentException E){
        LOGERROR(SendIntentException同时发动采购流程的SKU+ SKU);
        e.printStackTrace();        结果=新IabResult(IABHELPER_SEND_INTENT_FAILED,发送失败的意图。);
        如果(!监听= NULL)listener.onIabPurchaseFinished(结果,NULL);
    }
    赶上(RemoteException的E){
        LOGERROR(同时发动采购流程的SKU的RemoteException+ SKU);
        e.printStackTrace();        结果=新IabResult(IABHELPER_REMOTE_EXCEPTION,同时启动采购流程远程异常);
        如果(!监听= NULL)listener.onIabPurchaseFinished(结果,NULL);
    }
}


解决方案

我还没有尝试在应用程序内结算的认购,但据我所知检查我的回答如下。
 确保两招,你的产品给您的产品密钥是正确的。并在项目类型使用IabHelper.ITEM_TYPE_SUBS。

  1)静态最后弦乐SKU_SUBSCRIPTION =您的产品ID应该在这里;  2)mHelper.launchPurchaseFlow(youractivity.this,
                            SKU_SUBSCRIPTION,IabHelper.ITEM_TYPE_SUBS,
                            RC_REQUEST,mPurchaseFinishedListener,负载);

请让我体弱多病它是为你工作。希望它会帮助你。

检查IabHelper方式:

  //在launchPurchaseFlow注册了侦听器,我们有打电话回来时,
   //购买完成
   OnIabPurchaseFinishedListener mPurchaseListener;   公共无效launchPurchaseFlow(活动行为,字符串SKU,INT请求code,OnIabPurchaseFinishedListener听众){
       launchPurchaseFlow(ACT,SKU,请求code,监听器,);
   }   公共无效launchPurchaseFlow(活动行为,字符串SKU,INT请求code,
           OnIabPurchaseFinishedListener监听器,串extraData){
       launchPurchaseFlow(ACT,SKU,ITEM_TYPE_INAPP,请求code,监听器,extraData);
   }   公共无效launchSubscriptionPurchaseFlow(活动行为,字符串SKU,INT请求code,
           OnIabPurchaseFinishedListener监听){
       launchSubscriptionPurchaseFlow(ACT,SKU,请求code,监听器,);
   }   公共无效launchSubscriptionPurchaseFlow(活动行为,字符串SKU,INT请求code,
           OnIabPurchaseFinishedListener监听器,串extraData){
       launchPurchaseFlow(ACT,SKU,ITEM_TYPE_SUBS,请求code,监听器,extraData);
   }   / **
    *启动一个应用程序内购买的UI流程。调用此方法来启动一个应用程序内购买,
    *这将涉及造就了谷歌Play屏幕。调用活动将暂停,而
    *用户与谷歌播放相互作用,其结果将通过该活动的递送
    * {@link android.app.Activity#}的onActivityResult方法,在这一点,你必须调用
    *此对象的{@link #handleActivityResult}方法来继续购买流程。这种方法
    *必须从活动的UI线程调用。
    *
    * @Param行动调用的活动。
    *购买该项目的@param SKU的SKU。
    * @参数ITEMTYPE表示,如果它是一个产品或订阅(ITEM_TYPE_INAPP或ITEM_TYPE_SUBS)
    * @参数要求code的请求code(从其他的响应区分 -
    *在{@link android.app.Activity#startActivityForResult})。
    * @参数监听器监听通知在购买过程完成
    * @参数extraData额外的数据(开发有效载荷),将与购买数据返回
    *购买时完成。这个额外的数据将被永久绑定到购买
    *当购买查询总是会返回。
    * /
   公共无效launchPurchaseFlow(活动行为,SKU字符串,字符串ITEMTYPE,INT请求code,
                       OnIabPurchaseFinishedListener监听器,串extraData){
       checkSetupDone(launchPurchaseFlow);
       flagStartAsync(launchPurchaseFlow);
       IabResult结果;       如果(itemType.equals(ITEM_TYPE_SUBS)及&放大器;!mSubscriptionsSupported){
           IabResult R =新IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE,
                   订阅不可用。);
           如果(!监听= NULL)listener.onIabPurchaseFinished(R,NULL);
           返回;
       }       尝试{
           logDebug(买入建设为目的+ SKU +,项目类型:+ ITEMTYPE);
           捆绑buyIntentBundle = mService.getBuyIntent(3 mContext.getPackageName(),SKU,项目类型,extraData);
           INT响应= GETRESPONSE codeFromBundle(buyIntentBundle);
           如果(响应!= BILLING_RESPONSE_RESULT_OK){
               LOGERROR(无法购买物品,错误的回应:+ getResponseDesc(响应));               结果=新IabResult(响应,无法购买项目);
               如果(!监听= NULL)listener.onIabPurchaseFinished(结果,NULL);
               返回;
           }           的PendingIntent的PendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
           logDebug(启动购买意向为+ SKU +请求code:+请求code);
           mRequest code =请求code;
           mPurchaseListener =侦听器;
           mPurchasingItemType = ITEMTYPE;
           act.startIntentSenderForResult(pendingIntent.getIntentSender(),
                                          要求code,新意图()
                                          Integer.valueOf(0),Integer.valueOf(0),
                                          Integer.valueOf(0));
       }
       赶上(SendIntentException E){
           LOGERROR(SendIntentException同时发动采购流程的SKU+ SKU);
           e.printStackTrace();           结果=新IabResult(IABHELPER_SEND_INTENT_FAILED,发送失败的意图。);
           如果(!监听= NULL)listener.onIabPurchaseFinished(结果,NULL);
       }
       赶上(RemoteException的E){
           LOGERROR(同时发动采购流程的SKU的RemoteException+ SKU);
           e.printStackTrace();           结果=新IabResult(IABHELPER_REMOTE_EXCEPTION,同时启动采购流程远程异常);
           如果(!监听= NULL)listener.onIabPurchaseFinished(结果,NULL);
       }
   }

I created a subscription product and when people try to buy it, they click from my app to the app store, and they get an error "item not found"

But the items shows up as live in my developer console.

Here is how I call it:

Here is the onActivityResult() from this method:

protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    sendEmail(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data

results in this:

onActivityResult(10001,0,Intent { (has extras) }

and the onIabPurchaseFinished

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() 
{
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) 
    {
        sendEmail(TAG, "Purchase finished: " + result + ", purchase: " + purchase);

never seems to get executed.

And

public void onUpgradeAppButtonClicked( ) 
{
    sendEmail(TAG, "Buy button clicked; launching purchase flow for upgrade. SKU: " + SKU_SUBSCRIPTION + " and RC_REQUEST: " + RC_REQUEST );
    //setWaitScreen(true);
    mHelper.launchPurchaseFlow(this, SKU_SUBSCRIPTION, RC_REQUEST, mPurchaseFinishedListener);
}

resulted in this:

Buy button clicked; launching purchase flow for upgrade. SKU: my_sku and RC_REQUEST: 10001

Would anyone know why the error occured? Could it be that this happens in some older phones?

Also, if someone could try it on their phone maybe, that would help because I only have one phone to test with :) This is the link to the app: https://play.google.com/store/apps/details?id=com.problemio&hl=en

and to get to the billing is on the home screen the very bottom button.

EDIT:

I know that sometimes it takes time for the in-app product to truly go live in the Android system, but it says live in my dev console :)

EDIT:

In my IABHelper.java I have this:

/**
 * Same as calling {@link #launchPurchaseFlow(Activity, String, int, OnIabPurchaseFinishedListener, String)}
 * with null as extraData.
 */
public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener) {
    launchPurchaseFlow(act, sku, requestCode, listener, "");
}

and then this:

/**
 * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase,
 * which will involve bringing up the Google Play screen. The calling activity will be paused while
 * the user interacts with Google Play, and the result will be delivered via the activity's
 * {@link android.app.Activity#onActivityResult} method, at which point you must call
 * this object's {@link #handleActivityResult} method to continue the purchase flow. This method
 * MUST be called from the UI thread of the Activity.
 *
 * @param act The calling activity.
 * @param sku The sku of the item to purchase.
 * @param requestCode A request code (to differentiate from other responses --
 *     as in {@link android.app.Activity#startActivityForResult}).
 * @param listener The listener to notify when the purchase process finishes
 * @param extraData Extra data (developer payload), which will be returned with the purchase data
 *     when the purchase completes. This extra data will be permanently bound to that purchase
 *     and will always be returned when the purchase is queried.
 */
public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener, String extraData) {
    checkSetupDone("launchPurchaseFlow");
    flagStartAsync("launchPurchaseFlow");
    IabResult result;

    try {
        logDebug("Constructing buy intent for " + sku);
        Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, ITEM_TYPE_INAPP, extraData);
        int response = getResponseCodeFromBundle(buyIntentBundle);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logError("Unable to buy item, Error response: " + getResponseDesc(response));

            result = new IabResult(response, "Unable to buy item");
            if (listener != null) listener.onIabPurchaseFinished(result, null);
        }

        PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);
        logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode);
        mRequestCode = requestCode;
        mPurchaseListener = listener;
        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();

        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();

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

解决方案

I have not tried the subscription in app billing but according to my knowledge check my answer below. Make sure two thing your product key that you given for the product is correct. and use IabHelper.ITEM_TYPE_SUBS in the item type.

  1) static final String SKU_SUBSCRIPTION = "your product id should be here";

  2) mHelper.launchPurchaseFlow(youractivity.this,
                            SKU_SUBSCRIPTION, IabHelper.ITEM_TYPE_SUBS, 
                            RC_REQUEST, mPurchaseFinishedListener, payload); 

please let me infirm it is working for you. Hope it will help you.

check IabHelper method:

     // The listener registered on launchPurchaseFlow, which we have to call back when
   // the purchase finishes
   OnIabPurchaseFinishedListener mPurchaseListener;

   public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener) {
       launchPurchaseFlow(act, sku, requestCode, listener, "");
   }

   public void launchPurchaseFlow(Activity act, String sku, int requestCode, 
           OnIabPurchaseFinishedListener listener, String extraData) {
       launchPurchaseFlow(act, sku, ITEM_TYPE_INAPP, requestCode, listener, extraData); 
   }

   public void launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode, 
           OnIabPurchaseFinishedListener listener) {
       launchSubscriptionPurchaseFlow(act, sku, requestCode, listener, "");
   }

   public void launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode, 
           OnIabPurchaseFinishedListener listener, String extraData) {
       launchPurchaseFlow(act, sku, ITEM_TYPE_SUBS, requestCode, listener, extraData); 
   }

   /**
    * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase,
    * which will involve bringing up the Google Play screen. The calling activity will be paused while
    * the user interacts with Google Play, and the result will be delivered via the activity's
    * {@link android.app.Activity#onActivityResult} method, at which point you must call
    * this object's {@link #handleActivityResult} method to continue the purchase flow. This method
    * MUST be called from the UI thread of the Activity.
    *
    * @param act The calling activity.
    * @param sku The sku of the item to purchase.
    * @param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or ITEM_TYPE_SUBS)
    * @param requestCode A request code (to differentiate from other responses --
    *     as in {@link android.app.Activity#startActivityForResult}).
    * @param listener The listener to notify when the purchase process finishes
    * @param extraData Extra data (developer payload), which will be returned with the purchase data
    *     when the purchase completes. This extra data will be permanently bound to that purchase
    *     and will always be returned when the purchase is queried.
    */
   public void launchPurchaseFlow(Activity act, String sku, String itemType, int requestCode,
                       OnIabPurchaseFinishedListener listener, String extraData) {
       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.");
           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));

               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();

           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();

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

这篇关于Android的账单 - 项目未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆