dawnmenu
dawnmenu

Reputation: 41

Does JNI_OnLoad works with NativeActivity?

I am using NativeActivity and have setup and exported JNI_OnLoad in the shared library. But the JNI_OnLoad is not getting called !

Upvotes: 0

Views: 12

Answers (1)

dawnmenu
dawnmenu

Reputation: 41

No, JNI_OnLoad() wont work for the library called from NativeActivity (Credit). Instead, I guess ANativeActivity_onCreate() compensate for it.

As seen in android source, NativeActivity does not call System.loadLibrary() but calls loadNativeCode() which does dlopen() directly.

I had to use RegisterNatives() which could just as well be called in ANativeActivity_onCreate().

Android Dev is fun /s

Upvotes: 1

Related Questions