简体   繁体   中英

How to suppress "Cannot resolve corresponding JNI function" in Android Studio?

I am creating a native method in Android Studio which is registered using RegisterNatives in JNI_OnLoad when the library is loaded. The problem is that I want to encrypt the method name and signature strings, but if I do that Android Studio doesn't let me compile the app because of this error: "Cannot resolve corresponding JNI function Java_my_app_Native_initializeApplication." How can I suppress this?

Clicking the quick fix button gave me a pop up to add a @Suppress("KotlinJniMissingFunction") annotation to either the class or the file. You can keep it there or move it to all your methods, eg:

@Suppress("KotlinJniMissingFunction")
external fun initializeApplication()

or

@Suppress("KotlinJniMissingFunction")
class Native : AppCompatActivity() {
...
}

The equivalent annotation for Java is @SuppressWarnings("JavaJniMissingFunction") .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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