android - 使用 Android 应用内结算购买商品时(可能)出现未记录的错误

标签 android in-app-billing

我在使用 Android 的 IAB 进行购买时遇到问题。

我似乎能够获得 buyIntent,我使用从 IAB documentation 中获取的这段代码启动它:

Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
                    sku, "inapp", getString(R.string.iab_key));

int response = buyIntentBundle.getInt("RESPONSE_CODE");
if(response == 0) {
    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
    startIntentSenderForResult(pendingIntent.getIntentSender(),
                        1001, new Intent(), 0, 0, 0);
}

但是,当 Intent 启动时,我在应用程序和 onActivityResult 方法中收到一条错误消息,指出“不可能购买商品(错误代码 IAB-LPD)”(从意大利语大致翻译而来) , 做的时候

int responseCode = data.getIntExtra("RESPONSE_CODE", 0);

我的 responseCode 为 2,IAB API reference 中没有记录,因为它记录了错误代码 0、1、3、4 等等。

Api V2 Reference 说错误代码 2 是针对网络连接断开的情况,但我的设备的连接似乎工作正常。

我也没有在 Internet 上的任何地方找到任何对错误代码“IAB-LPD”的引用。

我尝试将我的许可证 key 更改为无效值,但我预计会收到一条错误消息,指出“此应用未获得计费授权”,因此我认为这不是我使用的许可证 key 的问题。

我错过了什么?

更新:我也不认为这是权限问题,因为我能够通过文档中描述的相同技术获取 SKU 详细信息。

进一步更新:我在 LogCat 中也没有收到任何错误,无论是在启动 Intent 还是在执行 onActivityResult 时。

最佳答案

我假设您看到的错误消息是

Impossibile acquistare l'articolo. (Codice di errore: IAB-LPD)

该消息的意大利语翻译似乎有错误(已翻译错误代码)。

您要查找的错误信息是

The item could not be purchased. (Error code: IAB-DPTL)

this question 的答案应该可以帮助您解决问题。

(对于给您带来的不便,我深表歉意,我提交了错误修复程序,应该会在即将发布的版本中修复。)

关于android - 使用 Android 应用内结算购买商品时(可能)出现未记录的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25694238/

相关文章:

android - 在应用程序计费没有 ui

java - 是否必须创建内部类来处理 DataBinding 中的事件?

安卓 SDK。无法启动 AVD

android - Android 中的应用内结算。具体方法?

Android In-App Billing 失败,提示 "You already have a pending order for this item."

android - 如何在我的 Android 应用程序中使用 In-app Billing API 版本 3 测试我的自动续订订阅?

android - 为什么 build.gradle 看起来不像 Groovy?

android - 状态 0 中的 MediaPlayer 错误 (-38,0)

android - ImageView selectableItemBackgroundBorderless 不会在 View 边界之外呈现

iphone - 如何收集信用卡信息