main.dart 文件的 main 函数中添加初始化代码。import 'package:bugly_pro_flutter/bugly.dart';void main() {Bugly.setSdkRegion(SdkRegion.BUGLY_CLOUD); // 设置上报域名BuglyOptions options = BuglyOptions(appId: '', appKey: '', bundleId: '');options.monitorTypes = [MonitorType.launchMetric,MonitorType.looperMetric,MonitorType.looperStack,MonitorType.exception];options.userId = 'pro_tester';Bugly.init(options, appRunner: (){runApp(const MyApp());},beforeInitRunner: (options){options.appId = 'afxxxxb01'; // 注册产品的appidoptions.appKey = 'aef434ba-xxxx-xxxx-xxxx-030b10aae88b'; // 注册产品的appkeyoptions.bundleId = 'com.xxx.bundleid';});}
import 'package:bugly_pro_flutter/bugly.dart';void main() {BuglyOptions options = BuglyOptions(appId: '', appKey: '', bundleId: '');options.monitorTypes = [MonitorType.launchMetric,MonitorType.looperMetric,MonitorType.looperStack,MonitorType.exception];options.userId = 'pro_tester';WidgetsFlutterBinding.ensureInitialized();final zone = Zone.current; // !!!!!!获取 zone!!!!!Bugly.init(options, appRunner: (){// runApp(const MyApp());zone.run(() => runApp(const MyApp())); // !!!!!!这里改成在 zone 中运行 runApp!!!!!!!},beforeInitRunner: (options){options.appId = 'afxxxxb01'; // 注册产品的 appidoptions.appKey = 'aef434ba-xxxx-xxxx-xxxx-030b10aae88b'; // 注册产品的 appkeyoptions.bundleId = 'com.xxx.bundleid';});}
Abort message: 'JNI DETECTED ERROR IN APPLICATION: java_class == null in call to GetStaticMethodID,且项目开启了代码混淆,需要将 Bugly 相关的类加入 keep 白名单。-keep class java.com.tencent.bugly.**{*;}
Clean Build(Cmd + Shift + K)后重新运行。flutter pub get 报依赖库冲突,可以先尝试将冲突的库版本改成业务使用的版本。例如业务依赖的 uuid 库版本是^4.4.2,但是 Flutter SDK 依赖的是^3.0.6,执行 flutter pub get 就会报错,可以在 pubspec.yaml 中添加如下内容,一般就能解决冲突问题。如果还是无法解决,请 提交工单 联系我们。# 将 uuid 依赖强制改写成4.4.2版本dependency_overrides:uuid: ^4.4.2
文档反馈