向Android Cordova插件添加依赖关系 [英] Add a dependency to an Android Cordova plugin

查看:1440
本文介绍了向Android Cordova插件添加依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立 Cordova Android外挂程式。我想在插件创建的 中使用 Intent 内的第三方查看 (特别是剪刀)。
通常(在非Cordova项目中)我会去我的项目的 build.gradle 文件,并添加如下:

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' }

但是,在我插件的项目中, build.gradle 文件似乎并不意味着触动?
为插件项目添加依赖项的正确方法是,通过Cordova支持这两个版本,并通过Android Studio构建它们?
同样的问题,但是对于本地项目(不是托管在GitHub上)。

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

推荐答案

gradle文件并将其链接到plugin.xml上像这样

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

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

你必须把这个标签放在plugin.xml上,所以插件安装它的读取和cordova句柄它(不知道它如何在内部工作,但我想它将值从您的自定义.gradle复制到主build.gradle)。所以你不能在你当前的项目上测试它,你必须创建一个新项目并添加插件,看看它是否工作

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

这篇关于向Android Cordova插件添加依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆