android - Flutter in_app_purchase 1.0.6 在 Android 设备上失败并显示错误消息:“W/BillingClient(15440): getSkuDetails() failed. Response code: 2”
问题描述
我已经设置了一个应用内项目,并在 Google Play 控制台上激活了它。
当我flutter run
在我的 android 设备上时,应用程序运行但它给出了以下错误日志。
W/BillingClient(15440): getSkuDetails() failed. Response code: 2
W/BillingClient(15440): getSkuDetails() failed. Response code: 2
根据下面的链接,这Response code: 2
意味着网络连接已断开或BILLING_RESPONSE_RESULT_SERVICE_UNAVAILABLE
.
https://developer.android.com/google/play/billing/billing_reference
据我所知,我的网络连接工作正常。如果有人能指出此错误的可能原因和解决方案,将不胜感激。
下面是我的代码:
import 'package:flutter/material.dart';
import 'package:in_app_purchase/in_app_purchase.dart';
const Set<String> _kProductIds = <String>{
'item_id',
};
class InAppItems with ChangeNotifier {
final InAppPurchase _inAppPurchase = InAppPurchase.instance;
InAppItems() {
setup();
}
void setup() async {
initStoreInfo();
}
Future<void> initStoreInfo() async {
final bool isAvailable = await _inAppPurchase.isAvailable();
if (!isAvailable) {
print('Store is not available!');
return;
}
print('Store is available!');
ProductDetailsResponse productDetailResponse = await _inAppPurchase.queryProductDetails(_kProductIds); // The failure occurs here
print('productDetailResponse error: ${productDetailResponse.error}');
print('product details is empty: ${productDetailResponse.productDetails.isEmpty}');
// other operations...
}
}
围绕错误的日志如下所示:
I/flutter (15440): Store is available!
W/BillingClient(15440): getSkuDetails() failed. Response code: 2
W/BillingClient(15440): getSkuDetails() failed. Response code: 2
I/flutter (15440): productDetailResponse error: null
I/flutter (15440): product details is empty: true
如果需要更多信息,请告诉我。
解决方案
推荐阅读
- go - OAuth 2 和管理服务器端的多个用户访问令牌
- django - 信号 django 运行任务
- thread-safety - 停止 IMFSourceReader 时,如何确保不会再次调用 OnReadSample?
- python - 如何使用re从python中的字符串中删除包含模式
- itext - 加载静态内容 pdf2Html Itext 7
- php - 它如何用 Laravel 中的 api 替换所有数据库功能
- sql - 了解此查询中的位置
- oracle - 通过 toad 连接到私有子网中的 Aws RDS
- sql - X时间后如何删除一些记录或文件 - Laravel 5
- sapui5 - 如何正确绑定异步。将数据从新闻 API 加载到视图并将数据显示为内容?