Beginner question - Building Cordova plugin with Android JNI

293 views
Skip to first unread message

joe....@itrinegy.com

unread,
May 24, 2017, 8:42:13 PM5/24/17
to android-ndk
Hi,

  I have managed to use NDK toolchains to cross compile our own executable for an Android platform. However, I need to put this executable into part of the Cordova android plugin. There is hardly any documentation on cordova Android plugin using JNI to call executable and how to package the whole plugin with JNI.

Can someone point me to the right direction?

Also, is there a way in NDK to build for all the possible android architectures? So my cordova plugin will eventually be able to run any android phone.

Thanks in advance
Joe


CONFIDENTIALITY NOTICE: This e-mail transmission and/or any attachments may contain confidential information belonging to the sender. Any unauthorised interception of this transmission is illegal under the law. If you have received this transmission in error, please promptly notify the sender by reply e-mail, and then destroy all copies of the transmission.

Alex Cohn

unread,
Jun 5, 2017, 8:30:52 AM6/5/17
to android-ndk
At least, https://github.com/clement360/Cordova-Hello-JNI-Plugin proves that codova with C++ is possible. As far as your second question is concerned, yes you can embed many so files in your 'universal' app:

<platform name="android"> ...
<source-file src="src/android/com/example/Hellojni/HelloJni.java" target-dir="src/com/example/plugin/" /> <source-file src="src/android/libs/armeabi-v7a/libhello-jni.so"target-dir="libs/armeabi-v7a/" /> <source-file src="src/android/libs/x86/libhello-jni.so"target-dir="libs/x86/" /> </platform>

But if you use an NDK standalone toolchain for building the so files, you must compile them one at a time. Nothing can prevent you from forging a wrapper script that will traverse all relevant ABIs. If you use ndk-build, then you can pass it an argument like APP_ABI="x86 armeabi-v7a mips" - and all required variations will be "installed" into libs directory.

BR,
Alex Cohn
Reply all
Reply to author
Forward
0 new messages