java.lang.UnsatisfiedLinkError:未找到实现

问题描述

我正在尝试在我的 android 应用程序中使用来自另一个存储库(已准备好使用本机代码)的本机代码。所以我需要从这个存储库中获取 libs 输出文件夹和 java 文件到我的项目。我遵循了以下程序:

从以前构建的存储库开始:

  1. 修改文件夹结构以及所有相关的源代码文件,以确保包名称与我当前的应用目标完全匹配。
  2. 确保 Android NDK 已安装并包含在 PATH 环境变量中。运行“ndk-build -B NDK_DEBUG=0”。在 libs 文件夹中获得了编译好的库。
  3. 将整个 libs 文件夹,包括我的应用项目的 app\src\main 下的所有子文件夹和内容以及 src/the/package/name 下的所有 Java 源代码(演示活动类除外)复制到我的应用项目。
  4. 在模块的 build.gradle 中添加了以下几行:
sourceSets.main {
    jni.srcDirs = [] // disable automatic ndk-build call
    jniLibs.srcDir 'src/main/libs/' // integrate your libs from libs instead of jniLibs
}

当我在应用程序中调用复制的 java 文件中的方法时,出现以下错误

2021-01-07 09:33:21.304 15856-15856/com.example.wbd_tws_demo E/le.wbd_tws_dem: No implementation found for void com.example.wbd_tws_demo.AndroidHRVAPIJNI.init_hrv_analysis() (tried Java_com_example_wbd_1tws_1demo_AndroidHRVAPIJNI_init_1hrv_1analysis and Java_com_example_wbd_1tws_1demo_AndroidHRVAPIJNI_init_1hrv_1analysis__)
2021-01-07 09:33:21.305 15856-15856/com.example.wbd_tws_demo D/AndroidRuntime: Shutting down VM
2021-01-07 09:33:21.305 15856-15856/com.example.wbd_tws_demo W/le.wbd_tws_dem: Accessing hidden method Lcom/msic/qarth/PatchStore;->createdisableExceptionQarthFile(Ljava/lang/Throwable;)Z (blacklist,JNI)
2021-01-07 09:33:21.305 15856-15856/com.example.wbd_tws_demo E/le.wbd_tws_dem: [qarth_debug:]  get PatchStore::createdisableExceptionQarthFile method fail.
2021-01-07 09:33:21.306 15856-15856/com.example.wbd_tws_demo E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.wbd_tws_demo,PID: 15856
    java.lang.UnsatisfiedLinkError: No implementation found for void com.example.wbd_tws_demo.AndroidHRVAPIJNI.init_hrv_analysis() (tried Java_com_example_wbd_1tws_1demo_AndroidHRVAPIJNI_init_1hrv_1analysis and Java_com_example_wbd_1tws_1demo_AndroidHRVAPIJNI_init_1hrv_1analysis__)
        at com.example.wbd_tws_demo.AndroidHRVAPIJNI.init_hrv_analysis(Native Method)
        at com.example.wbd_tws_demo.AndroidHRVAPI.init_hrv_analysis(AndroidHRVAPI.java:17)
        at com.example.wbd_tws_demo.BleOperations.onCreate(BleOperations.java:57)
        at android.app.Activity.performCreate(Activity.java:7458)
        at android.app.Activity.performCreate(Activity.java:7448)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
        at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:3409)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3614)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
        at android.os.Handler.dispatchMessage(Handler.java:112)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

我不知道为什么会出现此错误。我已经检查了其他答案的解决方案并尝试了它们,但没有任何运气。另外,我不是为什么在错误中,它说“尝试过 Java_com_example_wbd_1tws_1demo_AndroidHRVAPIJNI_init_1hrv_1analysis”。为什么那里有 1?我的包名称是 com.example.wbd_tws_demo。 1s正常吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)