NDK开发(二):java.lang.UnsatisfiedLinkError: Native method not found

本文探讨了在Java中遇到的java.lang.UnsatisfiedLinkError:Nativemethodnotfound问题,并提供了三种可能的解决方案,包括检查JNI方法名称的大小写、确保C++文件正确使用extern C以及处理传递给JNI方法的参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

java.lang.UnsatisfiedLinkError: Native method not found 三种可能解决方案

        so文件编译生成后,运行时,有时候会遇到java.lang.UnsatisfiedLinkError: Native method not found问题,有可能是以下三种因素:

一、Jni方法头部大小写问题     

在C++中,方法名:Java_com_XXX,而不是java_com_XXX。建议直接从生成的.h头文件直接复制方法名到C或者C++文件中。

二、C++文件问题

        如果是C++文件(.cpp或者.cc),要使用extern "C" {   } 把本地方法括进去。

三、往Jni方法中传值问题

         如,调用native方法sendSomeThing(Object object),如果传入的object为null,有可能会报上面错误。

07-22 18:02:18.502 11831 11831 I Typeface: Preloading /system/fonts/Roboto-Regular.ttf 07-22 18:02:18.542 11831 11831 V GraphicsEnvironment: ANGLE Developer option for 'com.taixin.txallremote' set to: 'default' 07-22 18:02:18.542 11831 11831 V GraphicsEnvironment: ANGLE GameManagerService for com.taixin.txallremote: false 07-22 18:02:18.543 11831 11831 V GraphicsEnvironment: Neither updatable production driver nor prerelease driver is supported. 07-22 18:02:18.544 11831 11831 D NetworkSecurityConfig: No Network Security Config specified, using platform default 07-22 18:02:18.545 11831 11831 D NetworkSecurityConfig: No Network Security Config specified, using platform default 07-22 18:02:18.545 11831 11831 I : application init 07-22 18:02:18.552 11831 11853 D libEGL : loaded /system/lib/egl/libEGL_emulation.so 07-22 18:02:18.553 11831 11853 I nemucooker: cook file1: /etc/mumu-configs/renderer.config, last modify time: Thu Aug 29 11:22:45 2024 07-22 18:02:18.553 11831 11853 I nemucooker: cook file2: /data/system/etc/mumu-configs/renderer.config, last modify time: Thu Jul 17 21:45:34 2025 07-22 18:02:18.553 11831 11853 I nemucooker: cook select file: /data/system/etc/mumu-configs/renderer.config 07-22 18:02:18.566 11831 11853 D libEGL : loaded /system/lib/egl/libGLESv1_CM_emulation.so 07-22 18:02:18.568 11831 11853 D libEGL : loaded /system/lib/egl/libGLESv2_emulation.so 07-22 18:02:18.590 11831 11853 E GraphicsEnv: Failed to get gpu service 07-22 18:02:18.599 11831 11831 I txallremote-H6RemoteIO: load library: libtxporting-i2c.so 07-22 18:02:18.600 11831 11831 E ziparchive: Zip: lseek on fd -2 failed: Bad file descriptor 07-22 18:02:18.625 11831 11831 I txallremote-H6RemoteIO: txallremote init 07-22 18:02:18.626 11831 11831 E xin.txallremot: No implementation found for void com.taixin.txallremote.jni.H6RemoteIO.TxAllRemote_Init() (tried Java_com_taixin_txallremote_jni_H6RemoteIO_TxAllRemote_1Init and Java_com_taixin_txallremote_jni_H6RemoteIO_TxAllRemote_1Init__) 07-22 18:02:18.626 11831 11831 D AndroidRuntime: Shutting down VM 07-22 18:02:18.627 11831 11831 E AndroidRuntime: FATAL EXCEPTION: main 07-22 18:02:18.627 11831 11831 E AndroidRuntime: Process: com.taixin.txallremote, PID: 11831 07-22 18:02:18.627 11831 11831 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for void com.taixin.txallremote.jni.H6RemoteIO.TxAllRemote_Init() (tried Java_com_taixin_txallremote_jni_H6RemoteIO_TxAllRemote_1Init and Java_com_taixin_txallremote_jni_H6RemoteIO_TxAllRemote_1Init__) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at com.taixin.txallremote.jni.H6RemoteIO.TxAllRemote_Init(Native Method) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at com.taixin.txallremote.jni.H6RemoteIO.remoteOpen(H6RemoteIO.java:17) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at com.taixin.txallremote.dataway.RemoteDirectIo.getInstance(RemoteDirectIo.java:27) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at com.taixin.txallremote.activity.TempHumiControlManagerActivity.onCreate(TempHumiControlManagerActivity.java:81) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8054) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8034) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1347) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3736) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3931) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2294) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8060) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 07-22 18:02:18.627 11831 11831 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1091) 07-22 18:02:18.651 11831 11831 I Process : Sending signal. PID: 11831 SIG: 9 07-22 18:02:18.673 1251 2855 I ActivityManager: Process com.taixin.txallremote (pid 11831) has died: fg TOP 07-22 18:02:18.673 1055 1055 I Zygote : Process 11831 exited due to signal 9 (Killed) 07-22 18:02:18.673 1251 1291 I libprocessgroup: Successfully killed process cgroup uid 10109 pid 11831 in 0ms 07-22 18:02:24.472 1091 1091 D opengl-gc: Check pid 11831: running 0
07-23
package com.taixin.txallremote.jni; import com.taixin.txallremote.utils.ALog; public final class H6RemoteIO { private static final String TAG = "H6RemoteIO"; private static final String libSoName = "txporting-i2c"; static { ALog.i(TAG, "load library: lib" + libSoName + ".so"); System.loadLibrary(libSoName); } public static void remoteOpen() { ALog.i(TAG, "txallremote init"); TxAllRemote_Init(); } public static void remoteLearnStart() { TxAllRemote_LearnStart(); } public static byte remoteReadData(byte[] buf, int count) { byte ack; ack = TxAllRemote_ReadData(buf, count); ALog.i(TAG, "ack:" + ack); return ack; } public static byte remoteWriteData(byte[] buf, int count) { byte ack; ack = TxAllRemote_WriteData(buf, count); return ack; } private static native void TxAllRemote_Init(); private static native void TxAllRemote_LearnStart(); private static native byte TxAllRemote_ReadData(byte[] paramArrayOfByte, int paramInt); private static native byte TxAllRemote_WriteData(byte[] paramArrayOfByte, int paramInt); } 07-23 08:31:32.909 22259 22282 D libEGL : loaded /system/lib64/egl/libEGL_emulation.so 07-23 08:31:32.910 22259 22259 I txallremote-H6RemoteIO: load library: libtxporting-i2c.so 07-23 08:31:32.929 22259 22259 D AndroidRuntime: Shutting down VM 07-23 08:31:32.929 22259 22282 I nemucooker: cook file1: /etc/mumu-configs/renderer.config, last modify time: Thu Aug 29 11:22:45 2024 07-23 08:31:32.929 22259 22282 I nemucooker: cook file2: /data/system/etc/mumu-configs/renderer.config, last modify time: Thu Jul 17 21:45:34 2025 07-23 08:31:32.929 22259 22282 I nemucooker: cook select file: /data/system/etc/mumu-configs/renderer.config 07-23 08:31:32.940 22259 22259 E AndroidRuntime: FATAL EXCEPTION: main 07-23 08:31:32.940 22259 22259 E AndroidRuntime: Process: com.taixin.txallremote, PID: 22259 07-23 08:31:32.940 22259 22259 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libtxporting-i2c.so" not found 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1086) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1006) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:1656) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at com.taixin.txallremote.jni.H6RemoteIO.<clinit>(H6RemoteIO.java:12) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at com.taixin.txallremote.jni.H6RemoteIO.remoteOpen(Unknown Source:0) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at com.taixin.txallremote.dataway.RemoteDirectIo.getInstance(RemoteDirectIo.java:27) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at com.taixin.txallremote.activity.TempHumiControlManagerActivity.onCreate(TempHumiControlManagerActivity.java:81) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8054) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8034) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1347) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3736) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3931) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2294) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8060) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 07-23 08:31:32.940 22259 22259 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1091) 07-23 08:31:32.945 22259 22282 D libEGL : loaded /system/lib64/egl/libGLESv1_CM_emulation.so 07-23 08:31:32.946 22259 22282 D libEGL : loaded /system/lib64/egl/libGLESv2_emulation.so 07-23 08:31:32.961 22259 22282 E GraphicsEnv: Failed to get gpu service 07-23 08:31:33.000 22259 22259 I Process : Sending signal. PID: 22259 SIG: 9 07-23 08:31:33.025 1251 10643 I ActivityManager: Process com.taixin.txallremote (pid 22259) has died: fg TOP 07-23 08:31:33.025 1054 1054 I Zygote : Process 22259 exited due to signal 9 (Killed) 07-23 08:31:33.025 1251 1291 I libprocessgroup: Successfully killed process cgroup uid 10111 pid 22259 in 0ms 07-23 08:31:40.589 1091 1091 D opengl-gc: Check pid 22259: running 0
最新发布
07-24
2025-07-14 16:23:05.430 10674-10674 nativeloader com.example.baiyunmap D Configuring clns-9 for other apk /data/app/~~6inlwRMbMcaLGIhM7fzZPA==/com.example.baiyunmap-sIji_tmuZqEGorhzhYsSuA==/base.apk. target_sdk_version=35, uses_libraries=, library_path=/data/app/~~6inlwRMbMcaLGIhM7fzZPA==/com.example.baiyunmap-sIji_tmuZqEGorhzhYsSuA==/lib/arm64:/data/app/~~6inlwRMbMcaLGIhM7fzZPA==/com.example.baiyunmap-sIji_tmuZqEGorhzhYsSuA==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.example.baiyunmap 2025-07-14 16:23:05.457 10674-10674 CompatChangeReporter com.example.baiyunmap D Compat change id reported: 202956589; UID 10220; state: ENABLED 2025-07-14 16:23:05.460 10674-10674 ample.baiyunmap com.example.baiyunmap I AssetManager2(0x77841ae48178) locale list changing from [] to [en-US] 2025-07-14 16:23:05.465 10674-10674 GraphicsEnvironment com.example.baiyunmap V Currently set values for: 2025-07-14 16:23:05.465 10674-10674 GraphicsEnvironment com.example.baiyunmap V angle_gl_driver_selection_pkgs=[] 2025-07-14 16:23:05.466 10674-10674 GraphicsEnvironment com.example.baiyunmap V angle_gl_driver_selection_values=[] 2025-07-14 16:23:05.466 10674-10674 GraphicsEnvironment com.example.baiyunmap V com.example.baiyunmap is not listed in per-application setting 2025-07-14 16:23:05.466 10674-10674 GraphicsEnvironment com.example.baiyunmap V ANGLE allowlist from config: 2025-07-14 16:23:05.466 10674-10674 GraphicsEnvironment com.example.baiyunmap V com.example.baiyunmap is not listed in ANGLE allowlist or settings, returning default 2025-07-14 16:23:05.466 10674-10674 GraphicsEnvironment com.example.baiyunmap V Neither updatable production driver nor prerelease driver is supported. 2025-07-14 16:23:05.569 10674-10674 nativeloader com.example.baiyunmap D Load libBaiduMapSDK_base_v7_6_5.so using class loader ns clns-9 (caller=/data/app/~~6inlwRMbMcaLGIhM7fzZPA==/com.example.baiyunmap-sIji_tmuZqEGorhzhYsSuA==/base.apk!classes3.dex): dlopen failed: library "libBaiduMapSDK_base_v7_6_5.so" not found 2025-07-14 16:23:05.569 10674-10674 AndroidRuntime com.example.baiyunmap D Shutting down VM 2025-07-14 16:23:05.571 10674-10674 AndroidRuntime com.example.baiyunmap E FATAL EXCEPTION: main Process: com.example.baiyunmap, PID: 10674 java.lang.UnsatisfiedLinkError: dlopen failed: library "libBaiduMapSDK_base_v7_6_5.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1090) at java.lang.Runtime.loadLibrary0(Runtime.java:1012) at java.lang.System.loadLibrary(System.java:1765) at com.example.baiyunmap.MapApplication.<clinit>(MapApplication.java:23) at java.lang.Class.newInstance(Native Method) at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76) at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52) at android.app.Instrumentation.newApplication(Instrumentation.java:1347) at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1479) at android.app.LoadedApk.makeApplicationInner(LoadedApk.java:1411) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7790) at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2546) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) ---------------------------- PROCESS ENDED (10674) for package com.example.baiyunmap ---
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值