ionic build 不成功很多时候是因为下载gradle太慢, 我们可以下载好gradle然后修改配置文件, 从而省去这个烦人的下载过程
1. 下载报错时的gradle zip文件, 或者直接查看步骤2里面的路径, 下载好后放到yourprojectplatformsandroidgradle
2. 修改配置文件 D:GitHubJiYiXunLianplatformsandroidcordovalibuildersGradleBuilder.js
// 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'] || '../gradle-3.3-all.zip';
3. 重新执行生成命令
ionic cordova build android
:assembleDebug
:cdvBuildDebug
BUILD SUCCESSFUL
Total time: 2 mins 49.348 secs
Built the following apk(s):
D:/GitHub/JiYiXunLian/platforms/android/build/outputs/apk/android-debug.apk