英文:
How to suppress "Cannot resolve corresponding JNI function" in Android Studio?
问题
我正在在Android Studio中创建一个本地方法,该方法在库加载时使用JNI_OnLoad中的RegisterNatives进行注册。问题是我想加密方法名和签名字符串,但如果我这样做,Android Studio不允许我编译应用程序,因为出现以下错误:“无法解析对应的JNI函数Java_my_app_Native_initializeApplication。”
如何抑制此错误?
英文:
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?
答案1
得分: 1
点击快速修复按钮会弹出一个窗口,要求添加@Suppress("KotlinJniMissingFunction")
注解到类或文件中。您可以将其保留在那里,或者将其移至所有方法,例如:
@Suppress("KotlinJniMissingFunction")
external fun initializeApplication()
或者
@Suppress("KotlinJniMissingFunction")
class Native : AppCompatActivity() {
...
}
对于Java,相应的注解是@SuppressWarnings("JavaJniMissingFunction")
。
英文:
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")
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论