Android应用计费

时间:2014-11-17 08:34:46

标签: android billing

我只有一个用于移除广告的产品。我实现了Google示例提供的所有方法。我在这里崩溃了:

mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                Log.d(TAG, "Setup finished.");

                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    Log.d(TAG, "Problem setting up In-app Billing: " + result);
                }
                // Hooray, IAB is fully set up!
                mHelper.queryInventoryAsync(mGotInventoryListener);
            }
        });

它说:

In-app billing error: Illegal state for operation (queryInventory): IAB helper is not set up.

我的清单文件中有<uses-permission android:name="com.android.vending.BILLING"/>。我还实施了onActivityResult

这是我在Google控制台上设置的产品: enter image description here

我更新了Google文档,它说应该发布您的应用内结算信息。我只是将其状态更改为活动状态,我不确定这是否是发布它的方式。

能再告诉我出了什么问题吗?感谢

编辑:

当结果不成功时,结果是:

IabResult: Error checking for billing v3 support. (response: 3:Billing Unavailable)

2 个答案:

答案 0 :(得分:1)

首先,您的代码有错误:即使结果没有成功,也会调用queryInventoryAsync。它应该像这样改变:

mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                Log.d(TAG, "Setup finished.");

                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    Log.d(TAG, "Problem setting up In-app Billing: " + result);
                }
                else {   <================= HERE!!
                    // Hooray, IAB is fully set up!    
                    mHelper.queryInventoryAsync(mGotInventoryListener);
                }
            }
        });

关于仪表板中的设置,您正确注册了应用内商品,但您还需要在ALPHA,BETA或PRODUCTION频道中发布至少一个版本的应用(我建议先在Alpha中进行一些测试,所以没有人会看到它)。你做到了吗?

答案 1 :(得分:0)

好的我通过以下方式解决了这个问题:

  • 在Google Console上发布的BETA APK
  • 更新了我的设备上的Google Play服务
  • 删除了设备上的Play商店缓存