我正在构建一个 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模板网!
更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 IncompIncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 Incompatible
如何在 gradle 中获取当前风味How to get current flavor in gradle(如何在 gradle 中获取当前风味)
如何修复“意外元素<查询>在“清单How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误
基于 Android Gradle 中多风味库的多风味应用Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多风味库的多风味应用)
Android 依赖在编译和运行时有不同的版本Android dependency has different version for the compile and runtime(Android 依赖在编译和运行时有不同的版本)
本地 aar 库的传递依赖Transitive dependencies for local aar library(本地 aar 库的传递依赖)