配置RevenueCat SDK后,当我尝试购买产品或打开付费墙时,此错误会显示在调试选项卡中并使我的应用程序崩溃。请注意,我现在只使用Android,因此所有内容都主要针对Play商店进行配置,因此我在没有检查平台的情况下配置了Google API Key。
这是登录后的init函数(我使用firebase登录,使用email登录revenuecat id)
Future<void> initPlatformState() async {
// Enable debug logs before calling `configure`.
await Purchases.setLogLevel(LogLevel.debug);
/*
- appUserID is nil, so an anonymous ID will be generated automatically by the Purchases SDK. Read more about Identifying Users here: https://docs.revenuecat.com/docs/user-ids
- observerMode is false, so Purchases will automatically handle finishing transactions. Read more about Observer Mode here: https://docs.revenuecat.com/docs/observer-mode
*/
PurchasesConfiguration configuration;
configuration = PurchasesConfiguration(googleApiKey)
..appUserID = null
..observerMode = false;
await Purchases.configure(configuration);
await Purchases.enableAdServicesAttributionTokenCollection();
appData.appUserID = await Purchases.appUserID;
Purchases.addCustomerInfoUpdateListener((customerInfo) async {
appData.appUserID = await Purchases.appUserID;
CustomerInfo customerInfo = await Purchases.getCustomerInfo();
(customerInfo.entitlements.all[entitlementID] != null &&
customerInfo.entitlements.all[entitlementID]!.isActive)
? appData.entitlementIsActive = true
: appData.entitlementIsActive = false;
//setState(() {});
});
}
@override
void initState() {
initPlatformState();
super.initState();
}
而这是一个应该在访问之前购买的产品
InkWell(
onTap: () async {
if (_isMathA == true) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const CourseMathAScreen()),
);
} else {
try {
Offerings offerings = await Purchases.getOfferings();
var package =
offerings.getOffering("Math A Course")?.lifetime;
await Purchases.purchasePackage(package!);
setState(() {
_isMathA = true;
});
} catch (e) {
debugPrint("Failed to purchase product: $e");
}
}
},
child: CourseWidget(
path: "assets/images/math.png",
title: "Mathematics A",
subtitle:
"MEXT Mathematics course A (beginner) broken down into chapters:\nNumbers and expressions\nQuadratic functions\nFigures and measurements\nThe number of possible outcomes and probability\nProperties of integers\nProperties of figures",
price: _isMathA ? "OPEN" : "\$17",
),
),
如果有帮助的话,这是我做的付费墙功能。这也会触发崩溃。
void checkUserPaywall(context, doFunction) async {
CustomerInfo customerInfo = await Purchases.getCustomerInfo();
if (customerInfo.entitlements.all[entitlementID] != null &&
customerInfo.entitlements.all[entitlementID]!.isActive == true) {
doFunction();
} else {
Offerings offerings;
try {
offerings = await Purchases.getOfferings();
if (offerings == null || offerings.current == null) {
//offerings are empty show message to user
} else {
//show paywall
await showModalBottomSheet(
useRootNavigator: true,
isDismissible: true,
isScrollControlled: true,
backgroundColor: Styles.orangeColor,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(25))),
context: context,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setModalState) {
return Paywall(
offering: offerings.current,
);
});
});
}
} on PlatformException catch (e) {
await showDialog(
context: context,
builder: (context) {
return SimpleDialog(
title: const Text("Error"),
children: [Text('${e.message}')],
);
});
}
}
}
This is the app build.这是应用构建。
dependencies {
def billing_version = "5.1.0"
implementation platform('com.google.firebase:firebase-bom:31.3.0')
implementation "com.revenuecat.purchases:purchases:6.0.0"
implementation "com.android.billingclient:billing:$billing_version"
implementation "com.android.billingclient:billing-ktx:$billing_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
我尝试构建一个appbundle,它也在我移动的上崩溃。我还尝试了pub clean,pub cache repair。我尝试删除依赖项中的计费客户端,但没有发生任何不同的情况。我很绝望,所以请帮助!
1条答案
按热度按时间6yt4nkrj1#
我也遇到了同样的问题。RevenueCat支持告诉我检查我在pubspec.yaml文件中使用的版本。截至本文,最新版本是4.11.1。
AI告诉我,我的SDK版本和Google Play Billing Library版本之间可能存在差异或不兼容。
在被卡住了几天之后,我注解掉了build.gradle文件中的一行代码
这似乎解决了我的问题。让我知道这是否有帮助!