0

我正在 Android 应用中实现应用内购买。我在 Google Play 开发者控制台中设置了应用程序并设置了几个产品。

根据 Android 文档,我将 IabHelper 和相关的计费文件添加到我的代码库中。我能够成功setup

        String base64EncodedPublicKey = Configurations.getInstance().getGooglePlayLicenseKey();
        googlePlayHelper = new IabHelper(AtavistApplication.getContext(), base64EncodedPublicKey);
        googlePlayHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    Utilities.log("Unable to setup billing: " + result);
                    isBillingSetup = false;
                } else {
                    Utilities.log("Billing setup successfully");
                    isBillingSetup = true;
                }
            }
        });

但是当我向 Google Play 查询产品信息时,如下所示:

   IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory)
        {
            if (result.isFailure()) {
                Utilities.log("getProducts failed");
                callback.failure(null);
            } else {
                Utilities.log("getProducts succeeded");
                callback.success(inventory);
            }
        }
    };

    googlePlayHelper.queryInventoryAsync(true, identifiers, mQueryFinishedListener);

identifiers字符串产品标识符列表在哪里:

    ArrayList<String> productIDs = new ArrayList<String>();
    productIDs.add("com.first.product");
    productIDs.add("com.second.product");
    productIDs.add("com.third.product");

我收到了一个成功的响应,其中仅包含一种产品,该产品不是在我的 Google Play 帐户中设置的产品。它的 productID 是我们之前提供的产品的 productID,但不久前它已从 Google Play 的活跃产品列表中删除。

问题:

  1. 为什么queryInventoryAsync不返回正确的列表?
  2. 为什么它会返回当前未在 Google Play 中设置的产品?
  3. 我是否缺少一些导致这种混乱的基本配置步骤?
4

1 回答 1

0

事实证明,我上传到 Google Play 开发者控制台(在设置产品之前)的 apk 与我正在构建和测试的代码库/apk 之间存在一些不协调。

具体来说,包标识符(包名称)不同,它们使用不同的密钥库进行签名。

不知道为什么这会返回一个看似有效的产品而不是一个明确的错误,但是将两个 apk 放在一起解决了这个问题。

于 2013-07-31T19:03:33.007 回答