我正在设置和测试应用内结算。我设法购买了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,即使我使用googles静态ID进行测试,这是否重要?
答案 0 :(得分:10)
解决了...... 静态购买ID似乎存在问题。 这是我在THIS帖子中找到的一种解法:
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".
答案 1 :(得分:2)
我找到了答案here:
"以下是建议:确保正确保存了结算密钥(base64EncodedPublicKey)。毕竟那是我的问题......"
base64EncodedPublicKey来自另一个应用......
这对我来说是解决方案。