`
贝壳水母
  • 浏览: 148025 次
  • 性别: Icon_minigender_1
  • 来自: 广州中低收入人群
社区版块
存档分类
最新评论

googlePlay接入小记

阅读更多
在GFW和google拐弯抹角的文档的关照下,调试googlePlay的登录和充值花了好多时间,分享一下遇到的问题和解决方法

1.充值测试手机环境
如果能登录play store,也绑定了visa/master信用卡,但是只能见到免费游戏和APP,请寻找一个境外ip的vpn……嗯,ip是重点。
直到能看到收费项目,就可以开始测试了,在这之前,如果进行iab的初始化,大概会报
Error checking for billing v3 support



==============================================================


2.添加测试账号
登录play game services需要在这里的“添加测试人员”加入测试账号:

也可以直接加入一个群组:



充值测试需要在这里的“许可测试”加:





==============================================================



3.各种报错
================================
In-app billing error: Unable to buy item, Error response: 7:Item Already Owned

这个问题源于iab的流程:http://developer.android.com/google/play/billing/api.html
一个商品支付完成后,需要被消费掉才能继续购买,所以参照例子在QueryInventoryFinishedListener和OnIabPurchaseFinishedListener适当的地方调用IabHelper的consumeAsync方法

================================
Error consuming response: 6:Error

加完consumeAsync我就遇到这个报错,消费失败,隐约记得这个报错是跟测试环境有关,但是搜半天搜不到解决办法,而且也无法继续测试支付了,就放着没管,时间是周五,结果周一回来打开手机居然就成功了,嗯,隐约记得上一次也好像是这样……好吧……google好像什么地方都有缓存,改个什么都得等半天才生效

================================
Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress

这是我一次支付完成之后,想要进行第二次支付报的错,大概就是第一次的支付没有结束云云,其实就是IabHelper的状态没有改变,支付完成之后没有调flagEndAsync()这个方法,后来发现是粗心了,在例子的MainActivity上,有这么一段代码
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
        if (mHelper == null) return;

        // Pass on the activity result to the helper for handling
        if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
            // not handled, so handle it ourselves (here's where you'd
            // perform any handling of activity results not related to in-app
            // billing...
            super.onActivityResult(requestCode, resultCode, data);
        }
        else {
            Log.d(TAG, "onActivityResult handled by IABUtil.");
        }
    }

里面的注释写得很明白了,需要在onActivityResult调一下IabHelper的handleActivityResult,里面就有一个操作
// end of async purchase operation that started on launchPurchaseFlow
        flagEndAsync();


================================
Unable to retrieve application xxxxxx from network
BasicNetwork.performRequest: Unexpected response code 401 for https://www.googleapis.com/games/v1/players/me?language=zh_CN
There is no linked app associated with this client ID.


Application ID xxxxxxx is not associated with package xx.xx.xx. Check the application ID in your manifest.



这都是使用非测试人员登录googlePlay出现的报错,或者play services没有打开alpha/beta测试人员的开关,参照第2点加入测试人员即可


================================
Access Not Configured. Please use Google Developers Console to activate the API for your project.


去到 https://console.developers.google.com/project
点开“APIs & auth”->"Credentials"->点击项目名

Signing-certificate fingerprint
填入keystore的SHA1的值


5. 参考文档
G+登录 https://developers.google.com/identity/sign-in/android/
play game services https://developers.google.com/games/services/android/quickstart
  • 大小: 113.6 KB
  • 大小: 27.8 KB
  • 大小: 62.8 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics