Best practices using JNI
summary
Use C++ wrappers instead of raw JNI to make the single line that does work obvious, handling J strings as substrings and primitive arrays with operator[] rather than Get/Release calls. Android provides LibNativeHelper (AOSP header only) and recommends a printf‑style exception helper to avoid convoluted exception chaining. For deployment prefer one big SO, store it uncompressed and use ReLinker when supporting older releases. The presenter reports getting 90% of the benefit for 20% of the effort.
AI-written summary · about
chapters (8)
- 0:00Introduction to JNI
- 0:17Problems with raw JNI code
- 0:43Improving JNI with C++
- 1:44Simplified exception handling
- 2:26Choosing helper libraries
- 2:59Code comparison and best practices
- 3:40Scalability and structure
- 4:24Advanced tips and conclusion








