简体   繁体   English

用于 Android/Cordova CLI 的 Gradle 版本

[英]Gradle version to use with Android/Cordova CLI

I currently use Cordova CLI on Windows to build hybrid Android apps.我目前在 Windows 上使用 Cordova CLI 来构建混合 Android 应用程序。 I am in the process of moving my development mover to a headless Ubuntu server.我正在将我的开发推动者转移到无头 Ubuntu 服务器。 Getting java, NVM, Node, Android SDK and Cordova CLI installed on Ubuntu has not been a problem.在 Ubuntu 上安装 java、NVM、Node、Android SDK 和 Cordova CLI 一直不是问题。 Having done so and created the customary Cordova hello world project,这样做并创建了惯用的 Cordova hello world 项目后,

cordova create hello com.example.hello HelloWorld

I proceeded to add the Android platform我继续添加Android平台

cordova plaform add android

and then attempted to build然后尝试构建

cordova build android

at which point I was told那时我被告知

Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper.错误:无法在 Android Studio 或您的系统上找到已安装的 Gradle 版本以安装 gradle 包装器。 Please include gradle in your path, or install Android Studio请在您的路径中包含 gradle,或安装 Android Studio

Installing Gradle by following the instructions given here - I am NOT installing Android Studio and am working on a headless Ubuntu machine so automatic Gradle installation is not an option - is not a problem.按照此处给出的说明安装 Gradle - 我不是在安装 Android Studio,而是在无头 Ubuntu 机器上工作,因此自动安装 Gradle 不是一个选项 - 不是问题。 However, it is not clear to me which version of Gradle I should install.但是,我不清楚应该安装哪个版本的 Gradle。

I do not want to break my current Cordova project so I am trying to replicate the current Windows/Cordova CLI setup as closely as I can我不想破坏我当前的 Cordova 项目,所以我试图尽可能地复制当前的 Windows/Cordova CLI 设置

  • Node 8.9.2节点 8.9.2
  • Java 8爪哇 8
  • Gradle ???摇篮???

Dipping inside the gradle-wrapper.properties file in my existing project I find gradle-wrapper.properties我现有项目中的gradle-wrapper.properties文件中,我发现

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

I have noted that when I compile the project at present there are some ominous warnings about features to be removed from future versions of Gradle that are shown.我已经注意到,当我目前编译项目时,会显示一些关于要从 Gradle 的未来版本中删除的功能的不祥警告。 I could experiment with using gradle-2.10 but it is not entirely clearr to me that it would indeed be the right version.我可以尝试使用 gradle-2.10,但我并不完全清楚它确实是正确的版本。 Hopefully, someone here will be able to point me in the right direction.希望这里的某个人能够为我指明正确的方向。

First, clean up the project一、清理项目

 cordova clean android

Then, force the cordova to use the distribution url with the version you want, in this case: gradle-6.3然后,强制cordova 使用您想要的版本的分发网址,在这种情况下: gradle-6.3

export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https\\://services.gradle.org/distributions/gradle-6.3-all.zip

Then, build your application.然后,构建您的应用程序。

cordova build android --release

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM