Ionic2 - Android 构建失败



我试图在我的Win 7(32 bt)系统上构建一个带有Android平台的Ionic2应用程序。

我在CLI中运行了ionic build android命令,并发生了以下错误:

...ionic build android
> ionic-hello-world@ ionic:build D:<path>
> ionic-app-scripts build
[20:12:32]  ionic-app-scripts 1.0.0
[20:12:32]  build dev started ...
[20:12:32]  clean started ...
[20:12:32]  clean finished in 10 ms
[20:12:32]  copy started ...
[20:12:32]  transpile started ...
[20:12:37]  transpile finished in 5.47 s
[20:12:37]  webpack started ...
[20:12:38]  copy finished in 5.74 s
[20:12:49]  webpack finished in 11.84 s
[20:12:49]  sass started ...
[20:12:52]  sass finished in 2.81 s
[20:12:52]  build dev finished in 20.16 s
[20:12:58]  tslint: D:/../src/app/app.component.ts, line: 3
            Unused import: 'OneSignal'
       L2:  import { Platform } from 'ionic-angular';
       L3:  import { StatusBar, Splashscreen, OneSignal } from 'ionic-native';
ANDROID_HOME=C:Users<user-name>AppDataLocalAndroidandroid-sdk
JAVA_HOME=C:Program FilesJavajdk1.8.0_60
Subproject Path: CordovaLib
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

然后按照建议,我阅读了"https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html"并创建了 gradle.properties 文件,其中包含以下内容

org.gradle.daemon=true

错误仍然存在,结果相同!!

出了什么问题??请帮忙.

经过一个小时的研发,找到了解决方案。

基本上按照"https://cordova.apache.org/docs/en/latest/guide/platforms/android/"——从cordova-android@4.0.0开始,Cordova for Android项目是使用Gradle构建的。早些时候,它是使用Apache Ant构建的。

现在,Gradle正在寻找最新的Android SDK。当我删除 android 平台并使用ionic platform add android命令再次添加时 - CLI 列出了最新的 Android SDK(在我的情况下是 SDK 24)未安装。

我使用Android SDK

管理器安装了所需的SDK版本,随后添加了Android平台以及cordova插件,顺利安装,没有任何错误。

CLI 打印了以下内容 -

..ionic plugin add onesignal-cordova-plugin
Fetching plugin "onesignal-cordova-plugin" via npm
Installing "onesignal-cordova-plugin" for android
ANDROID_HOME=C:Program Files (x86)Androidandroid-sdk
JAVA_HOME=C:Program FilesJavajdk1.8.0_121
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
:clean
:CordovaLib:clean
BUILD SUCCESSFUL
Total time: 1.611 secs
Subproject Path: CordovaLib

尝试使用cordova platform add https://github.com/apache/cordova-android

自从更新 Ionic 以来,我不得不开始使用这个命令。

相关内容

  • 没有找到相关文章

最新更新