I would like to include this Android library in a Cordova Plugin.
The library itself is managed by Gradle, as can be seen in the Github link. The developers of the library only provide guide how to use it in a Android Studio project, but I would like to create Cordova Plugin wrapper for this library, so I want to include it with the plugin.
My plugin has following structure:
-root
-plugin.xml
-lib
-fliclib-android (this is a cloned library from the github link)
-src
-android
-MyPlugin.java
-www
-MyPlugin.js
Inside of plugin.xml I have:
...
<js-module src="www/MyPlugin.js" name="MyPlugin">
<clobbers target="MyPlugin" />
</js-module>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="MyPlugin">
<param name="android-package" value="com.mypackage.cordova.MyPlugin"/>
</feature>
</config-file>
<source-file src="src/android/MyPlugin.java" target-dir="src/com/mypackage/cordova" />
<framework src="lib/fliclib-android/build.gradle" custom="true" type="gradleReference" />
</platform>
...
I have also tried:
<framework src="lib/fliclib-android/fliclib/build.gradle" custom="true" type="gradleReference" />
<framework src="lib/fliclib-android/" custom="true" />
<framework src="lib/fliclib-android/fliclib/src/main/" custom="true" />
...
I have also tried creating my own Gradle file inside lib/fliclib-android/fliclib/src/main
. So far no luck. When I try to run the cordova build
process, what I usually end up with is bunch of errors indicating that no class/symbol from the library was loaded.
Is it even possible to include project like this? It would be also great if I could just reference it from Github, but in the docu I did not find such option.
Or do I have to create an aar
file? And load that? I have not tried that option, but I would like to try that only in the last resort case.
Thank you!
I followed a different approach. It is funny that I developed the very same plugin and I didn't found your project!
My approach was to add a custom build.gradle file in my project. In the plugin.xml use the framework tag to specify the build.gradle location:
Then, the build.gradle contents are as follows:
It uses Jitpack to fetch the dependencies. It's working nice on Cordova, though I'm still having trouble building in the PhoneGap Build cloud solution.
This is my plugin, iOS support is on the way:
https://github.com/jguix/Cordova-Flic