Huawei ML Kit - 更新到 3.0.0.301 时图像分割应用程序崩溃

Huawei ML Kit - Image Segmentation App crash when updating to 3.0.0.301

该应用程序与以前的版本完美配合:

implementation 'com.huawei.hms:ml-computer-vision-segmentation:2.2.0.300'
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:2.2.0.300'
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:2.2.0.300'

现在当我更新到 3.0.0.301 时:

implementation 'com.huawei.hms:ml-computer-vision-segmentation:3.0.0.301'
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:3.0.0.301'
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:3.0.0.301'

应用程序崩溃,我收到此消息:

2021-08-04 00:35:50.103 32383-32383/maa.abc.background_changer E/ActivityThread: Failed to find provider info for com.huawei.hms

2021-08-04 00:35:50.109 32383-32383/maa.abc.background_changer E/AbstractInitializer: huawei_module_mlkit_imgseg -> No need to switch because the context of the dynamic module is null or the context of full sdk

2021-08-04 00:35:50.109 32383-32383/maa.abc.background_changer E/AbstractInitializer: huawei_module_mlkit_imgseg -> The context of the dynamic module belongs to LOCAL

2021-08-04 00:35:50.156 32383-32383/maa.abc.background_changer E/HIAI_DDK_MSG: /AiDllParser.cpp Load(45)::"dlopen load lib failed,lib[/system/lib64/libhiai_foundation.huawei.so],errmsg [dlopen failed: can't read file "/data/app/~~tmU2wHTAY38LvsdjeofDpA==/maa.abc.background_changer-QDVrIWUG8BkHCusrq3t_HQ==/lib/arm64": Is a directory]"

2021-08-04 14:02:10.286 7082-7082/? E/HIAI_DDK_MSG: /hiai_foundation_dl_helper.c HIAI_Foundation_GetSymbol(50)::"HIAI_Foundation_GetSymbol error."

2021-08-04 14:02:10.286 7082-7082/? E/HIAI_DDK_MSG: /hiai_version.c HIAI_GetVersion(66)::"sym HIAI_GetVersion not found."

2021-08-04 14:02:10.286 7082-7082/? E/HIAI_DDK_MSG: /AiDllParser.cpp Load(38)::"Load realpath failed in line 38"

2021-08-04 14:02:10.286 7082-7082/? E/HIAI_DDK_MSG: /AiDllParser.cpp Load(45)::"dlopen load lib failed,lib[/vendor/lib64/libai_client.so],errmsg [dlopen failed: can't read file "/data/app/~~mbQecxD1bZ8erjK-NEO8yw==/com.hauwei.mlkit.sample.gesturechangebackground-2NSWslAh4_jWMK0KxcOV1g==/lib/arm64": Is a directory]"

2021-08-04 14:02:10.286 7082-7082/? E/HIAI_DDK_MSG: /AiDllParser.cpp Load(38)::"Load realpath failed in line 38"

2021-08-04 14:02:10.286 7082-7082/? E/HIAI_DDK_MSG: /AiDllParser.cpp Load(45)::"dlopen load lib failed,lib[/system/lib64/libhiai_foundation.huawei.so],errmsg [dlopen failed: can't read file "/data/app/~~mbQecxD1bZ8erjK-NEO8yw==/com.hauwei.mlkit.sample.gesturechangebackground-2NSWslAh4_jWMK0KxcOV1g==/lib/arm64": Is a directory]"

2021-08-04 14:02:10.287 7082-7082/? E/HIAI_DDK_MSG: /ops_kernel_store_manager.cpp LoadComputeLibrary(396)::"hook function Initialize failed"

2021-08-04 14:02:10.287 7082-7082/? E/HIAI_DDK_MSG: /ops_kernel_store_manager.cpp RegComputeLibrary(303)::"RegComputeLibrary call LoadComputeLibrary fail"

2021-08-04 14:02:10.287 7082-7082/? E/V1CL: /rom_interface.cpp OpenClient(46)::"Open libai_client.so failed, error: dlopen failed: library "/vendor/lib64/libhiai_foundation.so" not found"

2021-08-04 14:02:10.287 7082-7082/? E/V1CL: /aicpv1cl_initialize.cpp Init(29)::"OpenClient failed"

2021-08-04 14:02:10.287 7082-7082/? E/HIAI_DDK_MSG: /ops_kernel_store_manager.cpp LoadComputeLibrary(396)::"hook function Initialize failed"

2021-08-04 14:02:10.287 7082-7082/? E/HIAI_DDK_MSG: /ops_kernel_store_manager.cpp RegComputeLibrary(303)::"RegComputeLibrary call LoadComputeLibrary fail"

2021-08-04 14:02:10.380 7082-7082/? A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 7082 (hangebackground), pid 7082 (hangebackground)

这是我的代码示例:

public class ImageSegmentation {

    private MLImageSegmentationAnalyzer analyzer;

    public void analyzer(Bitmap src, MLCallBack mlCallBack) {
        MLImageSegmentationSetting setting = new MLImageSegmentationSetting.Factory()
                .setExact(true)
                .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)
                .setScene(MLImageSegmentationScene.FOREGROUND_ONLY)
                .create();
        this.analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting);
        MLFrame mlFrame = new MLFrame.Creator().setBitmap(src).create();
        Task<MLImageSegmentation> task = this.analyzer.asyncAnalyseFrame(mlFrame);
        task.addOnSuccessListener(imageSegmentationResult -> {
            if (imageSegmentationResult != null) mlCallBack.onMLCompleted(imageSegmentationResult);
            else mlCallBack.onMLFailed();
        }).addOnFailureListener(e -> mlCallBack.onMLFailed());
    }

}

Gradle :

repositories {
    jcenter()
    mavenCentral()
    google()
    maven { url "https://jitpack.io" }
    maven { url "http://dl.bintray.com/vsmaks/maven" }
    maven { url "http://dl.bintray.com/dasar/maven" }
    maven { url 'https://developer.huawei.com/repo/' }
    maven() { url "https://oss.sonatype.org/content/repositories/snapshots" }
    maven {
        url "http://dl.bintray.com/piasy/maven"
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:4.2.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

Android工作室版本:Android工作室白狐2020.3.1

谢谢。

应用崩溃时间:

华为P8 Lite 2017 运行 Android 8.0

小米 POCO X3 NFC 运行 Android 11.0

感谢您的反馈。研发团队确认3.0.0.301版本有问题。因此,建议您使用较早版本的ML套件,该套件已在当前文档中进行了修改。

更多详情,可以参考这篇Docs