Is it possible to call a C++ library from an Android app? If yes, how?
I have zero experience in Android programming (some Java programming experience though) but I would still like to know if this is possible. Given the number of great C++ libraries out there, I would be surprised if it were not possible to call a C++ library from an Android app.
You need to write an Java Native Interface(JNI) to be able to call the native(c/c++) libraries from Android Java code.
The hierarchy is like:
+++++++++++++++++++++++++++++++++++
| Android Application |
+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++
| Android Application Framework |
+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++
| Java Native Interface |
+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++
| C/C++ Native Libraries |
+++++++++++++++++++++++++++++++++++
Yes, it's possible. You need to build your C++ library using the Android NDK. The new link https://developer.android.com/ndk/index.html
Yes you can. As previous posters mentioned you build your C++ library using the NDK and use JNI to call it from Java
If you're planning to make several C++ classes accessible you can use SWIG to automatically generate the JNI layer for you
我不知道它在Android中是否完全相同,但这是一个很棒的教程,帮助我在纯Java中与c ++集成http://www.javaworld.com/javaworld/javatips/jw-javatip17.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.