我正在设置和测试应用内结算。我设法购买了android.test.purchased,它做了应该做的事情。但是现在我需要使用它才能继续测试。问题是我无法到达库存。
调用此方法时,将得到结果。调用了isFaliure(),但无法获取 list 。
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();
}
};
它记录错误消息
android.test.purchased仍然是拥有的-它不会让我再次购买。我的手机具有网络连接,不是那样。
我尚未将签名的APK上传到Google Play,即使我使用Google的静态ID进行测试,这也有关系吗?
最佳答案
解决了...
静态购买ID似乎有问题。
这是在THIS线程中找到的解决方案IS:
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".
关于java - 刷新库存时出错。应用内结算,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26641052/