【问题标题】:Google In App BIlling Returns Null Purchases when calling getPurchasesGoogle In App BIlling 在调用 getPurchases 时返回 Null 购买
【发布时间】:2016-06-22 11:17:07
【问题描述】:

我编写了一个 IAB(应用内计费)应用程序。高级购买将提交到谷歌仪表板,我也可以看到该项目的发票,用户不能两次购买该项目。所以没关系。

但是通过使用下面的代码,我无法理解用户是否是高级用户,因为 premiumPurchase 始终是 null。 (我在设置完成的侦听器中调用此方法)

mHelper.queryInventoryAsync(new IabHelper.QueryInventoryFinishedListener() {
            public void onQueryInventoryFinished(IabResult result, Inventory inventory) {

                if (mHelper == null) return;

                if (result.isFailure()) {

                    return;
                }


                Purchase premiumPurchase = inventory.getPurchase(SKU_PREMUIM);

                if(premiumPurchase!=null) {
                    //Toast.makeText(getApplicationContext(),"permuim",Toast.LENGTH_SHORT).show();

                    lblIsPremuim.setText("You are Premium");
                }
                else{
                    lblIsPremuim.setText("You are Not Premium");
                    Toast.makeText(getApplicationContext(),"not permuim",Toast.LENGTH_SHORT).show();
                }

            }
});

我已重新启动设备并清除了 Google Play 的缓存,并且我确定我已使用正确的帐户登录。 base-64 公钥肯定是正确的,我已经阅读了 Stack-Over-Flow 中的所有帖子,这些帖子都提到了这个问题,但没有找到解决方案。我正在使用与上传的应用相同的版本名称和版本代码以及相同的密钥库。

【问题讨论】:

    标签: java android in-app-billing


    【解决方案1】:

    几天后,我终于通过操作 AndroidManifest.XML 文件解决了这个问题:

    1) 我已删除以下权限:(因为我认为这与计费权限冲突),但您可能可以离开此行。

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

    2) 我通知我的 AndroidManifest.xml 中有这样一行:

    <uses-sdk
            android:minSdkVersion="21"
            android:maxSdkVersion="9" />
    

    所以按照上面的说法, min 大于 max version ,这不合逻辑,所以我把它改成了下面的:

    <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" />
    

    之后我清理了项目并进行了重建并重新启动了设备。然后我可以得到我所有的购买......

    非常重要 更新:您应该从您的谷歌商店应用程序中登录退出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-06
      • 2013-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-27
      相关资源
      最近更新 更多