問題描述
我正在構(gòu)建一個(gè) Cordova Android 插件.我想在 由插件創(chuàng)建 的 Intent
中使用第 3 方 View
(特別是 剪刀).通常(在非 Cordova 項(xiàng)目中)我會(huì)轉(zhuǎn)到我的項(xiàng)目的 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' }
但我的插件項(xiàng)目中的 build.gradle
文件似乎不應(yīng)該被觸及?向插件項(xiàng)目添加依賴項(xiàng)以支持通過 Cordova 構(gòu)建和通過 Android Studio 構(gòu)建的正確方法是什么?同樣的問題,但針對(duì)本地項(xiàng)目(未托管在 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" />
您必須將該標(biāo)簽放在 plugin.xml
上,因此在插件安裝時(shí)它會(huì)被讀取并由 cordova 處理(不確定它是如何在內(nèi)部工作的,但我想它會(huì)從您的自定義 .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).
所以你不能在你當(dāng)前的項(xiàng)目上測試它,你必須創(chuàng)建一個(gè)新項(xiàng)目并添加插件,看看它是否有效
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
這篇關(guān)于向 Android Cordova 插件添加依賴項(xiàng)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!