cordova-docs
cordova-docs copied to clipboard
Document how to use Android NDK libraries in plugins
As discussed in https://github.com/dpa99c/cordova-plugin-hello-c/issues/8 ([1]) and https://github.com/litehelpers/Cordova-sqlite-storage/issues/729 ([2]) the change in the project directory structure caused issues with plugins using Android NDK libraries (with JNI).
I can think of the following alternative solutions, from least-recommended to most-recommended:
- Use new destination directory structure in
plugin.xml
, as done in https://github.com/dpa99c/cordova-plugin-hello-c/commit/b5f4d9c3085dd0c70a3d0a6fd84f39adb17a7ecd ([3]) (downside is that this solution will not work on cordova-android@6, consequentially not supporting Android pre-4.4) - Bundle the NDK objects in a JAR and use
lib-file
tags inconfig.xml
to add the JAR dependencies on Android, as described in https://github.com/litehelpers/Cordova-sqlite-storage/issues/729#issuecomment-355194460 ([4]) and [5]. This solution would work on both cordova-android@6 and cordova-android@7. - Use AAR from Maven as described in https://stackoverflow.com/questions/34115571/add-external-jar-library-to-build-cordova-plugin-ionic-framework/34129929#34129929 ([5]), like I did in https://github.com/brodybits/cordova-sqlcipher-adapter/commit/05a9166eb691faca9eeb135a8acdd748bd4df331 ([6])
[1] https://github.com/dpa99c/cordova-plugin-hello-c/issues/8 [2] https://github.com/litehelpers/Cordova-sqlite-storage/issues/729 [3] https://github.com/dpa99c/cordova-plugin-hello-c/commit/b5f4d9c3085dd0c70a3d0a6fd84f39adb17a7ecd [4] https://github.com/litehelpers/Cordova-sqlite-storage/issues/729#issuecomment-355194460 [5] https://stackoverflow.com/questions/34115571/add-external-jar-library-to-build-cordova-plugin-ionic-framework/34129929#34129929 [6] https://github.com/brodybits/cordova-sqlcipher-adapter/commit/05a9166eb691faca9eeb135a8acdd748bd4df331
What is the relevancy of this to the Cordova website and documentation?
Considering that the Android plugin development guide exists in https://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html (with source in https://github.com/apache/cordova-docs/blob/master/www/docs/en/dev/guide/platforms/android/plugin.md), I think some pointers how to use Android NDK libraries belong in this guide.