- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
谁能帮我找到我的错误,我看了看我似乎找不到它,我正在尝试运行我的代码但它一直给我错误 java.lang.UnsatisfiedLinkError: Native method未找到:nemo.lungu.receiptor.scanlibrary.ScanActivity.getPoints:(Landroid/graphics/Bitmap;)[F
下面是我的 Activity 方法getPoints()
:
public native float[] getPoints(Bitmap bitmap);
getPoints()
方法的 Header 版本:
JNIEXPORT jfloatArray JNICALL Java_nemo_lungu_receiptor_scanlibrary_ScanActivity_getPoints
(JNIEnv *, jobject, jobject);
最后是我的 .cpp
文件中方法 getPoints()
的实现:
JNIEXPORT jfloatArray JNICALL Java_nemo_lungu_receiptor_scanlibrary_ScanActivity_getPoints
(JNIEnv *env, jobject thiz,jobject bitmap)
{
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "Scaning getPoints");
int ret;
AndroidBitmapInfo info;
void* pixels = 0;
if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"AndroidBitmap_getInfo() failed ! error=%d", ret);
return 0;
}
if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888 )
{ __android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"Bitmap format is not RGBA_8888!");
return 0;
}
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME,"AndroidBitmap_lockPixels() failed ! error=%d", ret);
}
// init our output image
Mat mbgra(info.height, info.width, CV_8UC4, pixels);
vector<Point> img_pts = getPoints(mbgra);
jfloatArray jArray = env->NewFloatArray(8);
if (jArray != NULL)
{
jfloat *ptr = env->GetFloatArrayElements(jArray, NULL);
for (int i=0,j=i+4; j<8; i++,j++)
{
ptr[i] = img_pts[i].x;
ptr[j] = img_pts[i].y;
}
env->ReleaseFloatArrayElements(jArray, ptr, NULL);
}
AndroidBitmap_unlockPixels(env, bitmap);
return jArray;
正在像这样加载库:
static {
System.loadLibrary("myLibraryName");
}
这似乎加载成功,因为它给我消息 Added shared lib/data/app-lib/nemo.lungu.receiptor-2/myLibraryName.so 0xa4fe5e78
但在那之后它又给了我另一条消息说 No JNI_OnLoad found in/data/app-lib/nemo.lungu.receiptor-2/myLibraryName.so 0xa4fe5e78, skipping init
所以我不知道这是原因还是其他原因.
最佳答案
我需要将 extern "C"
放在我的 getPoints()
前面,因为 JNI
不理解 C++
命名转换,所以我的 .cpp
文件中的 getPoints()
方法需要看起来像 extern C JNIEXPORT jfloatArray JNICALL Java_nemo_lungu_receiptor_scanlibrary_ScanActivity_getPoints
(JNIEnv *env, jobject thiz, jobject 位图)
{//方法实现
关于java.lang.UnsatisfiedLinkError : Native method not found in Android 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36781353/
我有一个旨在在 Linux 环境中运行的 java 应用程序,它是使用 Opencv 和 Eclipse - Ubuntu 14.04 开发的。它在 Eclipse 中运行良好,并在导出时生成一个 .
我有一个 Android 项目,它使用具有相互依赖关系的库: Android 应用程序依赖于以下原生库 模块 tess-2(包含 tesseract 和 leptonica) 模块 opencv4an
我正在开发一个需要使用.so库的项目(ubuntu 18.04),当我将java代码放在/src文件夹中时一切正常(我使用的是IntelliJ Idea),但是在我移动之后我的代码放入命名包(smut
我创建了一个使用 autohotkey.dll 库的 jar 文件。 Jar 在我的主电脑和笔记本电脑上运行顺利,但现在我尝试在新安装了 Windows 10 的电脑上使用它,但收到此错误: Exce
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 8 年前。 Improve this ques
我创建了一个使用 google or-tools 的 spring 应用程序。为此,我使用 System.loadLibrary("jniortools") 导入 jniortools。当我提供 .d
我正在尝试使用我下载的小程序。使用时出现以下错误 Can't load library 'friend'. java.lang.UnsatisfiedLinkError:no friend in ja
我知道捕获错误不是一个好的做法,但在这种情况下,这样做很重要。我正在尝试运行一个包含游戏一部分的 jar,但它给了我一个 unsatisfiedlink 错误,但这是有趣的部分:我正在使用这段代码:
我正在尝试创建Java软件,该软件允许我启动程序并通过ActiveXComponent对其进行控制。为了使用ActiveXCompnent,我下载了一个名为“ jacob-1.18”的JAR文件。当我
我已经完成了大部分GWT MVP风格的测试,而没有测试小部件。我希望能够构建更复杂的小部件并对其进行良好的测试,而无需使用GwtTestCase(缓慢)。 出于好奇,我尝试了一个非常简单的测试。给一个
我正在使用 Proycon 将 .class 反编译为 .java,在我的库目录中包含 jd-core-java-1.0.jar 文件,但是当我编译 Main 类时它抛出异常 Exception in
我正在编写一个使用JNI的程序,当我在我的计算机上运行它时它工作正常,但如果我尝试在另一台计算机上运行它,它会抛出UnsatisfiedLinkError,说它找不到依赖库。我使用 Eclipse,并
我正在使用 javacpp 从 Java 访问 cpp。 我已经尝试过文档中提供的示例 cpp代码: CompletableFuture futureInC(){ @StdFuture
Error is :Exception in thread "main" java.lang.UnsatisfiedLinkError: jpcap.JpcapCaptor.getDeviceLi
我正在尝试使用 JNI 向 Java 公开 C++ 功能。我试图首先显示一个简单的消息框,只是为了确保一切正常。但是,我得到了一个 UnsatisfiedLinkError 异常被抛出(当我调用函数时
尝试使用来自 here 的代码我试图合并这两个类,以便最终得到 ulaw 音频数据的 inputStream。所以我像这样编辑了 UlawEncoderInputStream: private Mic
我正在使用 Android Studio 3,并尝试在我的设备上使用 OpenCL。APK 编译失败: java.lang.UnsatisfiedLinkError: dlopen failed: l
我正在开发 SIP 基础应用程序来调用和接听电话我对一个开源项目进行了分析 Sipdroid.除此之外,我制作此应用程序以支持 g729 编解码器。该应用程序工作正常,但是当我修改应用程序的包名称时,
我知道这个问题已经被问过了,但我没有找到任何方法来阅读现有代码来找到解决我的问题的方法。我的一些应用程序用户对不同类型的 UnsatifiedLinkError 有经验: Caused by: jav
我在 Windows 7 中使用 IntelliJ,在最近对我的开发系统(不是设备)进行了突然更改后,我陷入了 UnsatisfiedLinkError 的困境。由 System.loadLibrar
我是一名优秀的程序员,十分优秀!