说明
首先确定宿主端已按照华为的官方文档接入了鸿蒙flutter:https://gitee.com/openharmony-sig/flutter_flutter
请参考HarmonyOS Next SDK 集成引入原生SDK的依赖,并添加对应的权限
在 Flutter 项目的 pubspec.yaml
中添加 rangers_applog_flutter_plugin
依赖
dependencies: ...... rangers_applog_flutter_plugin: 1.4.1
并安装插件
flutter packages get
鸿蒙原生工程添加插件(一般安装依赖后会自动link上,需要自己检查一下)
import RangersApplogFlutterPlugin from 'rangers_applog_flutter_plugin'; // GeneratedPluginRegistrant.ets export class GeneratedPluginRegistrant { static registerWith(flutterEngine: FlutterEngine) { try { //这里添加RangersApplogFlutterPlugin flutterEngine.getPlugins()?.add(new RangersApplogFlutterPlugin()); } catch (e) { Log.e( TAG, "Tried to register plugins with FlutterEngine (" + flutterEngine + ") failed."); Log.e(TAG, "Received exception while registering", e); } } }