Search code examples
androidcordovacordova-plugins

Cordova plugin with v7-appcompat dependency


I'm trying to add a dependency to the android support v7 appcompat library to my Cordova plugin. I've tried many ways of doing this, but nothing seems to do the trick. I'm really surprised that I haven't been able to find a tutorial for this on the Cordova website or anywhere for that matter.


Solution

  • It turns out there was a very simple solution to this problem. Previously, I had checked the contents of my Android Library Project directly my Cordova Plugin. My Cordova Plugin is really just a wrapper for iOS and Android with a native bridge class for each.

    What I had tried to do was add the appcompat-v7 dependency to my plugin.xml. That didn't work.

    But because I distribute my Android Library Project as an .aar on central maven, I was able to modify my plugin.xml to simply include that file as a framework. Since my .aar had dependencies to appcompat-v7 and other libraries specified in the accompanying pom.xml, the normal Cordova build process worked perfectly.

    <platform name="android">
        <!--
          Your other plugin configuration options would go here.
        -->
        <framework src="com.your.package:your-artifact:1.0.0"/>
        <source-file src="src/android/YourBridge.java" target-dir="src/com/your/package/cordova"/>
    </platform>