![](/img/trans.png)
[英]GraphQL - Apollo - Android - Kotlin - Custom types are not getting generated even after specifying them in build.gradle
[英]Cordova android - How to replace custom build.gradle with generated
我有一個cordova項目,我在其中添加了android平台。 現在我需要使用我的 build.gradle 文件而不是生成的文件。
在 plugins.xml 中,我有以下代碼可以做到這一點。
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
但是在添加plugin的時候,這個build.gradle已經被放到了package下。看起來是這樣的。
// PLUGIN GRADLE EXTENSIONS START
apply from: "com.test.Name/Name-build.gradle"
// PLUGIN GRADLE EXTENSIONS END
我在生成的 build.gradle 中遇到了以下錯誤。
Error:(89, 0) Cannot convert relative path libs to an absolute file.
我需要我的自定義 build.gradle 替換自動生成的。 請告訴我如何在plugin.xml中指定這個我使用的cordova版本是6.1.1
官方cordova文檔的以下摘錄應該對您有所幫助,
擴展build.gradle
如果需要自定義build.gradle,而不是直接編輯它,則應創建名為build-extras.gradle的兄弟文件。 當存在時,主build.gradle將包含此文件。 此文件必須放在android平台目錄(/ platforms / android / app)的
app
文件夾中,因此建議您通過附加到before_build掛鈎的腳本將其復制。
這是一個例子:
// Example build-extras.gradle
// This file is included at the beginning of `build.gradle`
ext.cdvDebugSigningPropertiesFile = '../../android-debug-keys.properties'
// When set, this function allows code to run at the end of `build.gradle`
ext.postBuildExtras = {
android.buildTypes.debug.applicationIdSuffix = '.debug'
}
請注意,插件還可以通過以下方式包含build-extras.gradle文件:
<framework src="some.gradle" custom="true" type="gradleReference"/>
查看官方cordova文檔以獲取更多信息。 希望能幫助到你。
通過將名為gradle.properties
的文件放在您的 Android 平台文件夾(在<your-project>/platforms/android/app/gradle.properties
)並在其中設置屬性來設置自定義 gradle 文件,如下所示:
# In <your-project>/platforms/android/app/gradle.properties
cdvMinSdkVersion=20
但是,您可以通過設置環境變量來替換單個 gradle 屬性,如下所示:
$ export ORG_GRADLE_PROJECT_cdvMinSdkVersion=20
$ cordova build android
或者在 Cordova 構建或運行命令中使用 --gradleArg 標志,如下所示:
$ cordova run android -- --gradleArg=-PcdvMinSdkVersion=20
您還可以通過 build-extras.gradle 文件擴展 build.gradle 並像這樣設置屬性:
// In <your-project>/platforms/android/app/build-extras.gradle
ext.cdvMinSdkVersion = 20
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.