的Andr​​oid NDK的C ++ JNI(没有实现发现本机...) [英] Android NDK C++ JNI (no implementation found for native...)

查看:200
本文介绍了的Andr​​oid NDK的C ++ JNI(没有实现发现本机...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用NDK使用C ++和似乎无法获得方法命名约定正确的。我的家乡方法如下:

I'm trying to use the NDK with C++ and can't seem to get the method naming convention correct. my native method is as follows:

extern "C" {
JNIEXPORT void JNICALL Java_com_test_jnitest_SurfaceRenderer_drawFromJni
(JNIEnv* env, jclass c)
{
   //
}
}

一个头裹着的externC{} aslo。

with a header wrapped in extern "C" {} aslo.

一切都编译好,在我的项目,创建一个.so文件,并复制到libs文件夹,但是当我调试和运行在Eclipse中我不断收到一个日志猫消息不执行发现的原生......。是否有什么我失踪,因为所有的NDK的例子是C语言?

Everything compiles fine, creates a .so file and copies to the libs folder under my project, but when I debug and run in Eclipse I keep getting a log cat message that of "no implementation found for native...". Is there something i'm missing as all the NDK examples are in C?

感谢。

推荐答案

有几件事情,可导致没有实现找到。一个是获取函数原型的名字错了,另一种是没有加​​载。所以在所有。你确定的System.loadLibrary()被调用的方法是在使用之前?

There are a couple of things that can lead to "no implementation found". One is getting the function prototype name wrong, another is failing to load the .so at all. Are you sure that System.loadLibrary() is being called before the method is used?

如果你没有定义的JNI_OnLoad功能,您可能希望创建一个,把它吐出一个日志消息只是为了验证LIB是越来越拉到成功。

If you don't have a JNI_OnLoad function defined, you may want to create one and have it spit out a log message just to verify that the lib is getting pulled in successfully.

您已经躲过了最常见的问题 - 忘记使用的externC - 所以它无论是高于或一些轻微的拼写错误。什么是Java的声明是什么样子?

You already dodged the most common problem -- forgetting to use extern "C" -- so it's either the above or some slight misspelling. What does the Java declaration look like?

这篇关于的Andr​​oid NDK的C ++ JNI(没有实现发现本机...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆