2022-04-18 20:25:52.738 28123-28123/com.example.insectdetector E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.insectdetector, PID: 28123
java.lang.UnsatisfiedLinkError: No implementation found for boolean com.tsw.insectdetector.YoloV5Ncnn.Init(android.content.res.AssetManager) (tried Java_com_tsw_insectdetector_YoloV5Ncnn_Init and Java_com_tsw_insectdetector_YoloV5Ncnn_Init__Landroid_content_res_AssetManager_2)
at com.tsw.insectdetector.YoloV5Ncnn.Init(Native Method)
at com.tsw.insectdetector.DetectionHandler.<init>(DetectionHandler.java:36)
提示找不到boolean com.tsw.insectdetector.YoloV5Ncnn.Init函数的native实现,可能原因是找不到Java函数与native函数的映射关系。

该函数在jni.cpp中对应的函数名应该为

注意包名的对应,Java中以点.分隔,jni中以下划线_分隔
所在在Java中,com.tsw.insectdetector包下的函数在jni中应该为Java_com_tsw_insectdetector
在Android应用程序com.example.insectdetector运行时遇到了一个致命异常,具体表现为UnsatisfiedLinkError,指出无法找到YoloV5Ncnn类的Init函数的native实现。该问题可能是由于Java与C++之间的JNI映射不正确导致的,需要检查jni.cpp文件中Java_com_tsw_insectdetector_YoloV5Ncnn_Init函数的定义是否与Java代码相对应。
7万+

被折叠的 条评论
为什么被折叠?



