简体   繁体   English

无法解析相应的jni函数

[英]Cannot resolve corresponding jni function

i read a lot of posts but cannot resolve this yet. 我读了很多帖子,但还不能解决。

There is my error lines and structure of project: 这是我的错误行和项目结构: 错误和结构

Some libraries and configs I take from another project... And don't know where I went wrong. 我从另一个项目中获取的一些库和配置...而且我不知道哪里出错了。

I will give you source code of files if needed 如有需要,我将为您提供文件的源代码

工具

Thank you for any help. 感谢您的任何帮助。

I've also been getting this error since upgrading from Android Studio 2 to 3. The code compiles, but the IDE isn't recognizing the native functions. 从Android Studio 2升级到3之后,我也一直收到此错误。代码可以编译,但是IDE无法识别本机功能。 (This may be due to a preprocessor macro I've created that simplifies JNI function names.) (这可能是由于我创建的预处理器宏简化了JNI函数名。)

I've suppressed this error in Java by adding @SuppressWarnings("JniMissingFunction") before my class declaration. 我通过在类声明之前添加@SuppressWarnings("JniMissingFunction")抑制Java中的此错误。

Ok, so this missing 'JNI function' isn't a big deal. 好的,因此缺少“ JNI函数”没什么大不了的。 I know it's highlighted red, but the function is being linked, just not in a way that the IDE can determine. 我知道它以红色突出显示,但是该函数正在链接,只是没有以IDE可以确定的方式进行链接。

First, here's the relevant source code: https://github.com/koreader/crengine/blob/master/android/jni/cr3engine.cpp#L770 首先,这里是相关的源代码: https : //github.com/koreader/crengine/blob/master/android/jni/cr3engine.cpp#L770

CrEngine is linking the functions at run time. CrEngine在运行时链接功能。 The reason why your IDE isn't picking them up is because the CrEngine functions start with Java_org_ instead of Java_com_ . 您的IDE不能选择它们的原因是因为CrEngine函数以Java_org_而不是Java_com_ If you were relying on the engine to automatically link, this would be an issue, but as stated before, they are being explicitly linked at runtime with jniRegisterNativeMethods . 如果您依赖引擎自动链接,这将是一个问题,但是如前所述,它们是在运行时使用jniRegisterNativeMethods显式链接的。


Do a clean and update your build tools to 25.0.3 (or better) in your gradle.build file. 进行clean并将gradle.build文件中的构建工具更新为25.0.3(或更高版本)。 Update your SDKs and NDK. 更新您的SDK和NDK。 Then rebuild. 然后重建。 Some of the errors I saw could be caused by older build tools. 我看到的某些错误可能是由较早的构建工具引起的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM