Linli
Linli

Reputation: 31

Ionic can not build android

I am a starter to Ionic. When i build myfirst ionic app, i meet error.

 Error:Failed to run "java -version", make sure that you have a JDK installed.

 Error:D:\andorid\ionic\test\platforms\android\cordova\build.bat: command failed with exit code 2

      at ChildProcess.whenDone <C:\users\L\appdata\roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\suoerspawn.js:131:23>
      at ChildProcess. emit <events.js:110:17>
      at maybeClose <child_process.js:1008:16>
      at Process.ChildProcess._handle.onexit <child_process.js:1080:5>

Actulally my java environment was installed correctly. I can run "java -version".

Java version "1.8.0_20"
Java<TM> SE Runtime Environment <build 1.8.0_20-b26>
Java HotSpot<TM> 64-Bit Server VM <build 25.20-b23,mixed mode>

How to solve it?

Upvotes: 3

Views: 2641

Answers (1)

veerababu
veerababu

Reputation: 201

Try this

Open .bash_profile file with this

nano ~/.bash_profile

After adding

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=/usr/local/bin:$PATH

Upvotes: 5

Related Questions