You need to enable JavaScript to run this app.
导航
Flutter SDK 鸿蒙接入
最近更新时间:2024.12.03 17:05:45首次发布时间:2024.12.03 17:05:45

1 接入鸿蒙

说明

首先确定宿主端已按照华为的官方文档接入了鸿蒙flutter:https://gitee.com/openharmony-sig/flutter_flutter

1.1 引入鸿蒙埋点SDK

请参考HarmonyOS Next SDK 集成引入原生SDK的依赖,并添加对应的权限

1.2集成flutter插件

在 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);
    }
  }
}

1.3 其他集成步骤参考主文档即可

Flutter SDK 集成与埋点