Vova Kost
Vova Kost

Reputation: 13

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: error and structure

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

tools

Thank you for any help.

Upvotes: 1

Views: 8257

Answers (2)

Alan Kinnaman
Alan Kinnaman

Reputation: 927

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. (This may be due to a preprocessor macro I've created that simplifies JNI function names.)

I've suppressed this error in Java by adding @SuppressWarnings("JniMissingFunction") before my class declaration.

Upvotes: 9

James Poag
James Poag

Reputation: 2380

Ok, so this missing 'JNI function' isn't a big deal. I know it's highlighted red, but the function is being linked, just not in a way that the IDE can determine.

First, here's the relevant source code: https://github.com/koreader/crengine/blob/master/android/jni/cr3engine.cpp#L770

CrEngine is linking the functions at run time. The reason why your IDE isn't picking them up is because the CrEngine functions start with Java_org_ instead of 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.


Do a clean and update your build tools to 25.0.3 (or better) in your gradle.build file. Update your SDKs and NDK. Then rebuild. Some of the errors I saw could be caused by older build tools.

Upvotes: 4

Related Questions