Search code examples
androidcordovagradleandroid-gradle-plugincordova-plugins

Add a dependency to an Android Cordova plugin


I'm building a Cordova Android plugin. I want to use a 3rd party View inside an Intent that is created by the plugin (specifically scissors). Normally (in non Cordova projects) I would go to my project's build.gradle file and add it like this:

dependencies {
compile 'com.lyft:scissors:1.0.1' }

But it seems like the build.gradle file in my plugin's project wasn't meant to be touched? What is the proper way to add a dependency to a plugin project, to support both builds via Cordova and builds via Android Studio? Same question, but for a local project (not hosted on GitHub).


Solution

  • You have to use your own gradle file then link it on the plugin.xml like this

    <framework src="relative/path/your.gradle" custom="true" type="gradleReference" />
    

    You have to put that tag on the plugin.xml, so on plugin install it's read and cordova handles it (not sure how it works internally, but I suppose that it copies the values from your custom .gradle to the main build.gradle).

    So you can't test it on your current project, you have to create a new project and add the plugin and see if it works