Ionic Android 构建停止工作

Ionic Android build stopped working

我的 Ionic/Cordova 应用程序在更新 Ionic 和 Cordova CLI 后突然停止在 Android 上构建。在过去的 2 天里,我一直在 Google 中搜索解决方案,但我找不到任何有用的东西。我假设这与现在使用 Gradle 构建而不是 Apache Ant 的 Cordova 有关。我的 Android SDK 和构建工具都达到了版本 22,Gradle 2.2,Ant 1.9.4,JDK 8.

其他详情:
科尔多瓦 CLI:5.1.1
Ionic CLI 版本:1.6.1
离子应用程序库版本:0.3.3
OS: Mac OS X Yosemite 节点版本:v0.12.7

当我 运行 ionic 构建 android 时,我得到这个错误:

FAILURE: Build failed with an exception.

* Where:
Script '/platforms/android/CordovaLib/cordova.gradle' line: 128

* What went wrong:
A problem occurred evaluating root project 'android'.
> No match found

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.426 secs

/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /platforms/android/gradlew with args: cdvBuildDebug,-b,/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /platforms/android/cordova/build: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)

您可能需要在 config.xml 文件中设置 android-versionCode。我有一个类似的问题,通过将代码从“0.0.1”更改为“1”得到解决。显然 Android 想要一个整数值。

在我的 config.xml 中,我不得不改变这个:

<widget id="com.acme.appname" version="0.0.1" android-versionCode="0.0.1" ios-CFBundleVersion="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

对此:

<widget id="com.acme.appname" version="0.0.1" android-versionCode="1" ios-CFBundleVersion="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

android-versionCode

希望对您有所帮助。