cem94
May 11, 2018, 7:16pm
1
I’m developing a Cordova plugin in my Ionic project. In the plugin I need to integrate C code (JNI), but when I try to run the app on an Android device I find the error that can not find the jniLib (System.loadLibrary (“JNI”)). The code works, tested on intellIj idea.
Cordova version: 8.0.0
Files:
–plugin
----src
------android
---------(some java files)
---------JNI.java
---------c_code
------------JNI.h
------------JNI.c
---------libJNI.jnilib
----www
----plugin.xml
Don’t do this, create a seperate project for your plugin and use Plugman to create the basic scaffolding for your new plugin.
See: GitHub - apache/cordova-plugman: Apache Cordova Plugman
Development
Use the ‘–link’ command to link the plugin to your project, for example:
To add the plugin to your project:
cordova plugin add --link ../cordova-plugin-abrakm-sdk
To remove the plugin from your project:
cordova plugin rm cordova-plugin-abrakm-sdk
To check your project’s plugins:
ionic cordova plugin ls
Production
To add the plugin to your project:
ionic cordova plugin add cordova-plugin-abrakm-sdk
To remove the plugin from your project:
ionic cordova plugin rm cordova-plugin-abrakm-sdk
Using ‘C’ code in Apache Cordova Plugins