Setting Up Jni In Android Studio 3
I am using JNI in an Android Studio project I am working on. Currently, I have a C++ library that looks similar to this. #include ... extern 'C' { JNIEXPORT jobje
Solution 1:
You are 100% right, some JNI values beg to be cached and reused. Class references and method IDs are good examples. Please remember that FindClass() returns a local reference, so you need NewGlobalRef() for each class you keep in cache.
Android Studio does not help us with this setup, and I am not aware of reliable tools that can do such refactoring for us. You can learn good practices from open source code, e.g. from WebRTC JNI wrapper or from Spotify JNI helpers.
Android Studio can only keep track of the native methods, not of the cached objects, conversions, etc.
Post a Comment for "Setting Up Jni In Android Studio 3"