3

我无法找到如何摆脱/解决以下错误,这些错误在 使用 Android API >= 24的 DL4J 方法restoreMultiLayerNetwork加载神经网络模型时发生:

调用方法restoreMultiLayerNetwork中的以下行时会发生错误:

params = Nd4j.read(ins2);

InputStream ins2 = getResources().openRawResource(getResources().getIdentifier("coefficients", "raw", getPackageName()));

“coefficients.bin”是系数文件,在导出 DL4J 神经网络时通过以下方法从 DL4J 创建:

ModelSerializer.writeModel(model, locationToSave, saveUpdater);

错误:“类加载器命名空间”无法访问库

E/链接器:库“/vendor/lib64/libcutils.so”(“/vendor/lib64/libcutils.so”)需要或由“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu .so" 不可用于命名空间:[name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.arai.arai-1/lib/arm64:/system/fake-libs64 :/data/app/com.arai.arai-1/base.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a:/数据/app/com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data/ app/com.arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app/ com.arai.arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai。arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai- 1/split_lib_slice_7_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_8_apk.apk!

库“/vendor/lib64/libutils.so”(“/vendor/lib64/libutils.so”)需要或“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu.so”是命名空间不可访问:[name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.arai.arai-1/lib/arm64:/system/fake-libs64:/data/ app/com.arai.arai-1/base.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a:/data/app/ com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data/app/com. arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app/com.arai。 arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai。arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai- 1/split_lib_slice_7_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_8_apk.apk!/l

W/链接器:库“/system/lib64/libbinder.so”(“/system/lib64/libbinder.so”)需要或由“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu .so" 对于命名空间 "classloader-namespace" 是不可访问的 - 作为http://b/26394120的解决方法临时授予访问权限,请注意,该访问权限将在未来的 Android 版本中删除。

E/链接器:库“/vendor/lib64/libnativeloader.so”(“/vendor/lib64/libnativeloader.so”)需要或由“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu命名空间无法访问 .so":[name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/com.arai.arai-1/lib/arm64:/system/fake-libs64 :/data/app/com.arai.arai-1/base.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a:/数据/app/com.arai.arai-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a:/data/ app/com.arai.arai-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a:/data/app/ com.arai.arai-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a:/data /app/com.arai.arai-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a:/data/app/com.arai.arai-1/split_lib_slic

W /链接器:库“/system/lib64/libandroid_runtime.so”(“/system/lib64/libandroid_runtime.so”)需要或由“/data/app/com.arai.arai-1/lib/arm64/libjnind4jcpu .so" 对于命名空间 "classloader-namespace" 是不可访问的 - 作为http://b/26394120的解决方法临时授予访问权限,请注意,该访问权限将在未来的 Android 版本中删除。

Android 版本:API >= 24

从 build.gradle 中提取,其中设置了 ND4J 依赖项:

    android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "com.arai.arai"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath false
        }
        }


    buildTypes {
        release {
            minifyEnabled true
        shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    buildscript {
    configurations.all {
        resolutionStrategy {
            force 'net.sf.proguard:proguard-gradle:5.3.2'
        }
    }
    }

     packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/INDEX.LIST'

    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:design:27.1.0'

    compile (group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '1.0.0-beta2') {
    exclude group: 'org.bytedeco.javacpp-presets', module: 'opencv-platform'
    exclude group: 'org.bytedeco.javacpp-presets', module: 'leptonica-platform'
    exclude group: 'org.bytedeco.javacpp-presets', module: 'hdf5-platform'
    }      
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2'
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-arm64"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86"
    compile group: 'org.nd4j', name: 'nd4j-native', version: '1.0.0-beta2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'openblas', version: '0.3.0-1.4.2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.4.2-1.4.2', classifier: "android-x86_64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2'
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-arm64"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86"
    compile group: 'org.bytedeco.javacpp-presets', name: 'leptonica', version: '1.76.0-1.4.2', classifier: "android-x86_64"

    implementation 'com.google.code.gson:gson:2.8.2'
    annotationProcessor 'org.projectlombok:lombok:1.16.16'

    implementation 'com.google.code.findbugs:annotations:3.0.1', {
        exclude module: 'jsr305'
        exclude module: 'jcip-annotations'
    }

    //This corrects for a junit version conflict.
    configurations.all {
        resolutionStrategy.force 'junit:junit:4.12'
    }

}}
4

0 回答 0