我目前已经集成了ML kit的SDK,模块级build.gradle,应用级build.gradle,settings.gradle都配置好了,签名也ok了,AppGallery的SHA256证书指纹也添加了,代码是示例代码:
//设置手势分析器的属性
val setting = MLGestureAnalyzerSetting.Factory().create()
//创建手势分析器,但是调用getGestureAnalyzer()方法时,报错
val analyzer = MLGestureAnalyzerFactory.getInstance().getGestureAnalyzer(setting)
//设置识别结果处理器,实现分析器与结果处理器的绑定
analyzer.setTransactor(HandAnalyzerTransactor())
//捕捉相机动态视频流并传入分析器
//创建LensEngine对象
//传入分析器
//设置分析器类型为LensEngine.BACK_LENS
//设置分辨率和帧率
val lensEngine =
LensEngine.Creator(applicationContext, analyzer).setLensType(LensEngine.BACK_LENS).applyDisplayDimension(640, 480)
.applyFps(25.0f).create()
surfaceView = findViewById(R.id.surfaceView)
try {
lensEngine.run(surfaceView.holder)
} catch (e: IOException) {
Log.d(tag, e.toString())
}
具体报错如下:
E/MLInitializerProvider: MLInitializerProvider Done
E/CountryCodeBean: getVendorCountry=cn
E/AbstractInitializer: huawei_module_mlkit_gesture -> isForce = false, isCreatorClassRemote = true, isLocalExisted = true
E/AbstractInitializer: huawei_module_mlkit_gesture -> The context of the dynamic module belongs to REMOTE
E/HaLogProvider: initlizeHaSdk APK mode,BUILD_MODE=APK
再仔细检查一下相关的配置文件,SDK 和依赖库已经正确集成了么