gpt4 book ai didi

android - Cordova android - 如何用生成的自定义 build.gradle 替换

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:40:46 24 4
gpt4 key购买 nike

我有一个 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

If you need to customize build.gradle, rather than edit it directly, you should create a sibling file named build-extras.gradle. This file will be included by the main build.gradle when present. This file must be placed in the app folder of the android platform directory (/platforms/android/app), so it is recommended that you copy it over via a script attached to the before_build hook.

这是一个例子:

// 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"/>

查看 offical cordova documentation获取更多信息。希望对您有所帮助。

关于android - Cordova android - 如何用生成的自定义 build.gradle 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37066565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com