googlePlay接入小记

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

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



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


2.添加测试账号
登录play game services需要在这里的“添加测试人员”加入测试账号:
[img]http://dl2.iteye.com/upload/attachment/0111/0002/2bd2e274-a815-3248-88e9-57f214d0a05c.png[/img]
也可以直接加入一个群组:
[img]http://dl2.iteye.com/upload/attachment/0111/0004/30434993-32d4-3ada-aa04-77a040799fca.png[/img]


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

[img]http://dl2.iteye.com/upload/attachment/0111/0006/4a30767d-9a9b-316c-afeb-c98cd7b7cb00.png[/img]


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


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

这个问题源于iab的流程:[url]http://developer.android.com/google/play/billing/api.html[/url]
一个商品支付完成后,需要被消费掉才能继续购买,所以参照例子在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.


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

Signing-certificate fingerprint
填入keystore的SHA1的值


5. 参考文档
G+登录 [url]https://developers.google.com/identity/sign-in/android/[/url]
play game services [url]https://developers.google.com/games/services/android/quickstart[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值