向 Android Cordova 插件添加依赖项

时间:2023-02-02
本文介绍了向 Android Cordova 插件添加依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在构建一个 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 插件添加依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:Wear App 和带有 applicationIdSuffix 的自定义构建类型 下一篇:使用不同的版本代码进行调试/发布 android gradle build

相关文章

最新文章