gpt4 book ai didi

android - Google 的 IAB API3 getSkuDetails() 方法返回失败 5 : Developer Error

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:21:45 25 4
gpt4 key购买 nike

我正在尝试将 Google 的应用内结算 API3 合并到我一直在使用 API2 的代码中。

我对 mHelper(IabHelper 对象)的调用成功了,所以我正在连接到 Google 的服务器。看来我可以确定拥有的元素,因为我的 QueryInventoryFinishedListener 返回一个包含我购买的所有元素的有效库存。我也可以执行购买。

但是,查询 sku 详细信息失败 (getSkuDetails())。以下是导致失败的所有来自 Eclipse 的 IabHelper 相关 LogCat 输出(我删除了我的包名称和产品 SKU):

12-31 11:47:04.642: D/IabHelper(13633): Starting in-app billing setup.
12-31 11:47:04.832: D/IabHelper(13633): Billing service connected.
12-31 11:47:04.832: D/IabHelper(13633): Checking for in-app billing 3 support.
12-31 11:47:04.832: D/IabHelper(13633): In-app billing version 3 supported for com.XXXX.XXXX
12-31 11:47:04.832: D/IabHelper(13633): Subscriptions AVAILABLE.
12-31 11:47:04.842: D/IabHelper(13633): Starting async operation: refresh inventory
12-31 11:47:04.842: D/IabHelper(13633): Querying owned items, item type: inapp
12-31 11:47:04.842: D/IabHelper(13633): Package name: com.XXXX.XXXX
12-31 11:47:04.842: D/IabHelper(13633): Calling getPurchases with continuation token: null
12-31 11:47:04.912: D/IabHelper(13633): Owned items response: 0
12-31 11:47:04.912: D/IabHelper(13633): Sku is owned: com.XXXX.XXXX.item_one
12-31 11:47:04.922: D/IabHelper(13633): Sku is owned: com.XXXX.XXXX.item_two
...
(and 45 other items)
...
12-31 11:47:05.012: D/IabHelper(13633): Continuation token: null
12-31 11:47:05.012: D/IabHelper(13633): Querying SKU details.
12-31 11:47:05.012: D/IabHelper(13633): getSkuDetails() failed: 5:Developer Error
12-31 11:47:05.012: D/IabHelper(13633): Ending async operation: refresh inventory

这似乎不是签名问题,因为我可以成功连接并进行购买。

有没有其他人遇到过 getSkuDetails() 失败并显示“开发者错误”消息,而应用内计费的其他方面正常的问题?

感谢您的宝贵时间!

最佳答案

我遇到过同样的问题。当您的库存中有超过 20 个 SKU 时,似乎会出现此问题。

解决方案是以 block 的形式获取 SKU 详细信息。将 IabHelper.java 中的 querySkuDetails 替换为:

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
throws RemoteException, JSONException {
logDebug("Querying SKU details.");
ArrayList<String> skuList = new ArrayList<String>();
skuList.addAll(inv.getAllOwnedSkus(itemType));
if (moreSkus != null) {
for (String sku : moreSkus) {
if (!skuList.contains(sku)) {
skuList.add(sku);
}
}
}

if (skuList.size() == 0) {
logDebug("queryPrices: nothing to do because there are no SKUs.");
return BILLING_RESPONSE_RESULT_OK;
}

while (skuList.size() > 0) {
ArrayList<String> skuSubList = new ArrayList<String>(
skuList.subList(0, Math.min(19, skuList.size())));
skuList.removeAll(skuSubList);

Bundle querySkus = new Bundle();
querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuSubList);
Bundle skuDetails = mService.getSkuDetails(3,
mContext.getPackageName(), itemType, querySkus);

if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
int response = getResponseCodeFromBundle(skuDetails);
if (response != BILLING_RESPONSE_RESULT_OK) {
logDebug("getSkuDetails() failed: "
+ getResponseDesc(response));
return response;
} else {
logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
return IABHELPER_BAD_RESPONSE;
}
}

ArrayList<String> responseList = skuDetails
.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

for (String thisResponse : responseList) {
SkuDetails d = new SkuDetails(itemType, thisResponse);
logDebug("Got sku details: " + d);
inv.addSkuDetails(d);
}
}
return BILLING_RESPONSE_RESULT_OK;
}

此方法以 18 个为一组获取 SKU。它对我有用。

关于android - Google 的 IAB API3 getSkuDetails() 方法返回失败 5 : Developer Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20862280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com