Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a dependency to an Android Cordova plugin

Tags:

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).

like image 224
YakirNa Avatar asked Dec 16 '15 14:12

YakirNa


People also ask

Is Cordova discontinued?

Apache Cordova Is Retired: Alternatives for Cross Platform Mobile Development in 2022. Future trends of cross-platform mobile development are already starting to emerge, and it appears that Apache Cordova won't be included in the list of frameworks that power hybrid web apps for mobile devices.

How do I add a plugin to config xml Cordova?

When adding plugins or platforms, use the --save flag to add them to config. xml. Ex: cordova platform add android --save. Existing projects can use cordova plugin save and cordova platform save commands to save all previously installed plugins and platforms into your project's config.


1 Answers

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

like image 124
jcesarmobile Avatar answered Sep 21 '22 00:09

jcesarmobile