我正在构建一个 Cordova Android 插件.我想在 由插件创建 的 Intent
中使用第 3 方 View
(特别是 剪刀).通常(在非 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 then 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 插件添加依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!