Android的应用程序中购买计费验证失败 [英] android in app billing purchase verification failed

查看:237
本文介绍了Android的应用程序中购买计费验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我'有实施应用内结算在我的Andr​​oid应用程序的麻烦。 我得到一个购买签名验证失败。 在我第一次坚持到底是关键的base64,但我检查了很多次,我仍然得到错误,那么以后我看了看Security.java文件,我发现这个方法,我编辑的得到一些信息关于什么是错的:

i' having trouble implementing in app billing in my android app. i'm getting a purchase signature verification failed. In a first time i tough it was the base64 key but i checked it many times and i'm still getting the error, then after i took a look at the Security.java file and i found this method which i edited for get some informations about what was wrong:

    public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {
    if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) ||
            TextUtils.isEmpty(signature)) {
        if(TextUtils.isEmpty(signedData)) Log.d(TAG, "SIGNED DATA EMPTY");
        if(TextUtils.isEmpty(base64PublicKey)) Log.d(TAG, "KEY IS EMPTY");
        if(TextUtils.isEmpty(signature)) Log.d(TAG, "SIGNATURE IS EMPTY");
        Log.e(TAG, "Purchase verification failed: missing data.");
        return false;
    }

    PublicKey key = Security.generatePublicKey(base64PublicKey);
    return Security.verify(key, signedData, signature);
}

和我得到签名是空的。 我按照下面的步骤即使在: -sign的APK跟我开关键 -upload它作为一个草案 与亚行-d安装app.apk

And i'm getting "signature is empty". Even after i follow the steps below: -Sign the apk with my release key -upload it as a draft -install it on a device with "adb -d install app.apk"

我测试与真正的购买。 谢谢你。

I'm testing with real purchases. Thanks.

修改的购买流程是好的,我得到的错误,当我打电话 queryInventoryAsync

Edit The purchase flow is fine, i get the error when i call queryInventoryAsync

推荐答案

下面请更换你的 verifyPurchase()方法。使用下面,鉴于旧的code,谷歌开发者试图解决在不久的将来这个错误,但他们更新了自己的code之前,您应该低于$ $ C $中c p $ PFER。

Replace your verifyPurchase() method with below one. Use old code that given below, google developer are trying to solve this error in the near future but before they updated their code you should prefer below code.

 public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {
              if (signedData == null) {
                Log.e(TAG, "data is null");
                return false;
            }

            boolean verified = false;
            if (!TextUtils.isEmpty(signature)) {
                PublicKey key = Security.generatePublicKey(base64PublicKey);
                verified = Security.verify(key, signedData, signature);
                if (!verified) {
                    Log.w(TAG, "signature does not match data.");
                    return false;
                }
            }
            return true;
        }

检查此链接了解更多信息:

check this link for more information:

<一个href="http://stackoverflow.com/questions/19534210/in-app-billing-not-working-after-update-google-store/19539213#19539213">In应用内结算工作不更新后 - 谷歌商店

使用尝试更换旧的code方法 verifyPurchase()方法,在您的项目。但是,它应该是唯一的,当你试图购买测试产品发生。让我知道真正的产品使用该code后还可以购买。

Use try to replace OLD CODE method verifyPurchase() method in your project. But It should be only happens when you are trying to purchase test products. Let me know for the real products purchase also after using this code.

编辑:

为什么会发生,因为当我们使用的是像android.test.purchased虚拟产品,我们不会得到任何签名。因此,在旧code这是工作好,因为我们是返回true,即使签名不给,并为新的code,我们返回false。

Why it happens because we will not get any signature while we are using dummy product like "android.test.purchased". So in the old code it is working good because we were return true even if signature is not given and for the New code we are returning false.

有关签名的详细信息数据空或空白的链接1和链接2

more information about the signature data null or blank from link1 and link2

所以,我建议你只是更换旧的code方法 verifyPurchase(),而不是新的code方法。

So I suggest you just replace old code method verifyPurchase() instead of New Code method.

我觉得可能是新的code将正常工作为真正的产品,但不是在虚拟的产品。但我却为真正的产品还没有测试过。

I think may be New Code will work fine for the real product but not in the dummy product. But yet I have not tested for the real product.

使用GVS的回答为试买这也为新的code的好办法。

use GvS's answer for the test purchases it also the good solution for the new code.

希望这本书能解决你的问题。

Hope it will solve your problem.

这篇关于Android的应用程序中购买计费验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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