我正在设置和测试应用内结算。我设法购买了 android.test.purchased,它做了它应该做的事情。但现在我需要消耗它来继续我的测试。问题是我无法到达库存。
当调用它时,我得到 result.isFaliure() 被调用,但我无法获取库存。
IabHelper.QueryInventoryFinishedListener _gotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (_iabHelper == null) return;
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
_isPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
Log.d(TAG, "User is " + (_isPremium ? "PREMIUM" : "NOT PREMIUM"));
update();
}
};
它记录错误消息
查询库存失败:IabResult:刷新库存时出错
(查询拥有的物品)。 (响应:-1003:购买签名
验证失败)
android.test.purchased 仍然是拥有的 - 它不会让我再次购买它。我的手机有网络连接,所以不是这样的。
我还没有将签名的 APK 上传到 Google Play,即使我使用 google 静态 ID 进行测试,这也有关系吗?
解决了...
静态购买 ID 似乎存在问题。
这是找到的解决方案THIS https://stackoverflow.com/questions/14600664/android-in-app-purchase-signature-verification-failed thread:
If you have used the android.test.purchased then one way to get rid of the error is to do the following:-
1. Edit Security.java and change the "return false" line in the
verifyPurchase to "return true" - this is temporary, we'll be
putting it back in a minute.
2. In your QueryInventoryFinishedListener, after the "if
(result.isFailure()) {...}" lines add the following to consume and
get rid of your never ending android.test.purchased item:-
if (inventory.hasPurchase(SKU_ANDROID_TEST_PURCHASE_GOOD)) {
mHelper.consumeAsync(inventory.getPurchase(SKU_ANDROID_TEST_PURCHASE_GOOD),null);
}
3. Run your app so the consunmeAsync happens, this gets rid of the
"android.test.purchased" item on the server.
4. Remove the consumeAsync code (or comment it out). Back in the
Security.java, change the "return true" back to "return false".
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)