Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 922
Linli Avatar asked May 18 '26 09:05

Linli


1 Answers

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
like image 157
veerababu Avatar answered May 20 '26 22:05

veerababu