我创建了 ionic 2 项目并添加了这样的诊断 cordova 插件:
ionic plugin add cordova.plugins.diagnostic npm install --save @ionic-native/diagnostic
并像这样添加android平台:
ionic platform add android@latest
但是当使用控制台构建时ionic build android给我这个错误:
ionic build android
Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio
我尝试手动下载 gradle.3.3-all.zip 并在 platform/android/cordova/lib/builders/GradleBuilder.js 中更改此 distributionUrl var
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-3.3-all.zip'
至:
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'file:///E:/gradles/gradle-3.3-all.zip';
但不工作和控制台给了我最后一个错误。
我不知道如何为 android@latest 版本添加 gradle
尝试安装 gradle 并将其包含在您的路径中。单击下面的链接以获取手册。 https://gradle.org/install