javaandroidmachine-learninghuawei-mobile-serviceshuawei-ml-kit

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


The app was working perfectly with the previous version :

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'

Now when I updated to 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'

The app crash and I get this message :

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)

Here's an example of my code:

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 Studio version : Android Studio arctic fox 2020.3.1

Thank you.

The app crashes on :

Huawei P8 Lite 2017 running Android 8.0

Xiaomi POCO X3 NFC running Android 11.0


Solution

  • Thank you for your feedback. The R&D team confirms that the version 3.0.0.301 is faulty. Therefore, it is recommended that you use an earlier version of the ML kit, which has been modified in the current document.

    enter image description here

    For more details, You can refer to this Docs.