Reputation: 6363
I have an .so file that I added to Android Studio 2.1.1. Everything is working well and I can call the method from the .so file. The only thing is that for it to work I need to call the native method from a very specific part in my app.
Eg the method name is Java_com_test_app_MainView_myMethod
, and so I must call myMethod
from a class called MainView
in a package named com.test.app
.
So if I rename MainView
to SubView
I get java.lang.UnsatisfiedLinkError: Native method not found: com.test.app.SubView.myMethod
.
Is this supposed to work like this, or am I missing something?
Upvotes: 0
Views: 210
Reputation: 2220
This is indeed supposed to work like this. JNI method names must mirror the JAVA method names in _
format.
From this doc, following rules must be observed:
Resolving Native Method Names
Dynamic linkers resolve entries based on their names. A native method name is concatenated from the following components:
- a mangled fully-qualified class name
- an underscore (“_”) separator
- a mangled method name
- for overloaded native methods, two underscores (“__”) followed by the mangled argument signature
Upvotes: 2