You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法使用android.test.purchased测试内购流程,求解决方案

应用内购测试问题:android.test.purchased弹窗购买按钮无法点击

问题描述

我习惯使用android.test.purchased测试应用内购买流程,但近期出现异常:测试弹窗中的购买按钮无法点击。相关代码如下:

测试代码

ProductDetails productDetails = skuDetailsINAPMap.get(productId);

if (productDetails == null) {
    return "Product ID invalid";
}
ImmutableList<BillingFlowParams.ProductDetailsParams> productDetailsParamsList =
        ImmutableList.of(
                BillingFlowParams.ProductDetailsParams.newBuilder()
                        .setProductDetails(productDetails)
                        .build()
        );

BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
        .setProductDetailsParamsList(productDetailsParamsList)
        .build();

BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);

错误现象

测试弹窗弹出后,购买按钮处于不可点击状态。

解决建议

  • 升级Billing Library版本:确保使用最新的Google Play Billing Library(推荐v6.x),旧版本可能存在测试商品交互的兼容性问题。
  • 验证商品详情有效性:获取productDetails后打印日志,确认productId为android.test.purchased,且title、description等字段正常加载,排除商品详情获取不全的问题。
  • 补充BillingFlowParams参数:尝试添加setObfuscatedAccountId("test_account")或setObfuscatedProfileId("test_profile")参数到BillingFlowParams构建器中,部分场景下缺少用户标识参数会导致按钮禁用。
  • 清除缓存数据:清除应用自身缓存以及Google Play商店的缓存和数据,重启设备后重新测试,避免本地缓存的旧购买状态干扰。
  • 确认测试账号权限:确保测试账号已添加到Google Play Console的许可测试列表,且该账号未持有未消费的android.test.purchased商品(可通过consumeAsync接口消费已购买的测试商品)。
  • 检查设备环境:确保设备登录有效Google账号,且Google Play服务为最新版本,避免因服务版本过低导致交互异常。

内容的提问来源于stack exchange,提问作者LamLT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 11:30:57