简体   繁体   中英

Ionic2 - Android build failed

I was trying to build an Ionic2 app with Android platform on my Win 7 (32 bt) system.

I ran the ionic build android command in the CLI and the following error occurred :

...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>\AppData\Local\Android\android-sdk

JAVA_HOME=C:\Program Files\Java\jdk1.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

Then as suggested I read the ' https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html ' and created the gradle.properties file with the following

org.gradle.daemon=true

The error still persists with the same result !!!

What is going wrong ?? Please help .

Found the solution after a hour long R&D.

Basically as per ' https://cordova.apache.org/docs/en/latest/guide/platforms/android/ ' - As of cordova-android@4.0.0, Cordova for Android projects are built using Gradle. Earlier it was built using Apache Ant.

Now Gradle looks for latest Android SDK. When I removed the android platform and added again with ionic platform add android command - the CLI listed that the latest Android SDK ( in my case it was SDK 24 ) was not installed.

I installed the required SDK version using Android SDK Manager and subsequent add of Android Platform along with the cordova plugin smoothly installed without any error.

The CLI printed the following -

..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)\Android\android-sdk

JAVA_HOME=C:\Program Files\Java\jdk1.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

Try using cordova platform add https://github.com/apache/cordova-android

Ive had to start using this command ever since updating Ionic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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