Issue-JniOnLoad
For reporting issue https://issuetracker.google.com/issues/220523932.
Guide
The core source files are following:
- foo.cc, the code of library foo, with NO JNI_OnLoad defined.
- bar.cc, the code of library bar, with JNI_OnLoad defined.
- CMakeLists.txt, defines libraries foo, bar and their relationship.
- MainActivity, load libraries foo and bar.
Steps to reproduce issue
- Run the code
- Click text "CLICK ME TO EXECUTE"
- You will see the logcat output:
2022-02-21 15:38:27.116 12825-12825/com.example.foo D/Bar: JNI_OnLoad: count = 1
2022-02-21 15:38:27.117 12825-12825/com.example.foo D/Bar: JNI_OnLoad: count = 2
2022-02-21 15:38:27.117 12825-12825/com.example.foo D/Foo: call function of library bar: 3
which means the JNI_OnLoad of libbar.so was called twice.