Как импортировать библиотеку с открытым исходным кодом с JNI, NDK - PullRequest
0 голосов
/ 29 июня 2018

Я хочу использовать эту библиотеку в своем проекте для ее редактирования. Итак, я установил NDK и также установил путь к NDK-комплекту. Но эта ошибка выходит в мой журнал.

6-29 15:14:42.174 15069-15069/com.softcode.kihnoplay E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.softcode.kihnoplay, PID: 15069
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.softcode.kihnoplay-1/base.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.softcode.kihnoplay-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.softcode.kihnoplay-1/lib/arm, /data/app/com.softcode.kihnoplay-1/base.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/com.softcode.kihnoplay-1/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libARM_ARCH.so"
    at java.lang.Runtime.loadLibrary0(Runtime.java:972)
    at java.lang.System.loadLibrary(System.java:1567)
    at FFmpegAndroid.src.main.java.com.github.hiteshsondhi88.libffmpeg.ArmArchHelper.<clinit>(ArmArchHelper.java:5)
    at FFmpegAndroid.src.main.java.com.github.hiteshsondhi88.libffmpeg.CpuArchHelper.getCpuArch(CpuArchHelper.java:16)
    at FFmpegAndroid.src.main.java.com.github.hiteshsondhi88.libffmpeg.FFmpeg.loadBinary(FFmpeg.java:38)
    at com.softcode.tablet.Mp3Concat_Thread.startThread(Mp3Concat_Thread.java:93)
    at com.softcode.tablet.Mp3Concat_Thread.<init>(Mp3Concat_Thread.java:53)
    at com.softcode.phone.record.view.RecordActivity.onCreate(RecordActivity.java:183)
    at android.app.Activity.performCreate(Activity.java:6955)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Это ArmArchHelper.class в библиотеке с открытым исходным кодом.

package FFmpegAndroid.src.main.java.com.github.hiteshsondhi88.libffmpeg;

class ArmArchHelper {
static {
    System.loadLibrary("ARM_ARCH");
}

native String cpuArchFromJNI();

boolean isARM_v7_CPU(String cpuInfoString) {
    return cpuInfoString.contains("v7");
}

boolean isNeonSupported(String cpuInfoString) {
    // check cpu arch for loading correct ffmpeg lib
    return cpuInfoString.contains("-neon");
}

}

И это armArch.c в библиотеке в папке ini.

#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <cpu-features.h>

 JNIEXPORT jstring JNICALL
  Java_com_github_hiteshsondhi88_libffmpeg_ArmArchHelper_cpuArchFromJNI(JNIEnv* env, jobject obj)
{
char arch_info[11] = "";

// checking if CPU is of ARM family or not
if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) {
    strcpy(arch_info, "ARM");

    // checking if CPU is ARM v7 or not
    uint64_t cpuFeatures = android_getCpuFeatures();
    if ((cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
        strcat(arch_info, " v7");

        // checking if CPU is ARM v7 Neon
        if((cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
            strcat(arch_info, "-neon");
        }
    }
}
return (*env)->NewStringUTF(env, arch_info);
}

Если вы сейчас как решить эту проблему, пожалуйста, дайте мне знать. Спасибо.

1 Ответ

0 голосов
/ 29 июня 2018

Вы компилируете файл armArch.c в libARM_ARCH.so? еще если вы компилируете, чтобы сказать libsomething.so, тогда измените команду на System.loadLibrary («что-то»)

...