Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to build Android Emulator with ionic fails.. "Class not found: javac1.8" [duplicate]

I'm trying to emulate android using ionic framework's "ionic emulate android" command.

But it throws an exception..

 [aapt] Generating resource IDs...
 [echo] ----------
 [echo] Handling BuildConfig class...
 [buildconfig] Generating BuildConfig class.

 -pre-compile:

 -compile:

 BUILD FAILED
 C:\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:601: The following er
 ror occurred while executing this line:
 C:\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:720: The following er
 ror occurred while executing this line:
 C:\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:734: Class not found:
  javac1.8

 Total time: 1 second

 C:\PhoneApps2\myApp2\platforms\android\cordova\node_modules\q\q.js:126
                throw e;
                      ^
 Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\PhoneApps2\myApp2
 \platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
 Error: cmd: Command failed with exit code 8
     at ChildProcess.whenDone (C:\Users\Colin\AppData\Roaming\npm\node_modules\co
 rdova\src\superspawn.js:112:23)
     at ChildProcess.EventEmitter.emit (events.js:98:17)
     at maybeClose (child_process.js:730:16)
     at Process.ChildProcess._handle.onexit (child_process.js:797:5)
 Unable to emulate app on platform android. Please see console for more info.

I have the latest versions of JRE and JDK installed.. in my System Variables;

JRE_HOME:  C:\Program Files (x86)\Java\jre8
JAVA_HOME: C:\Program Files (x86)\Java\jdk1.8.0
ANT_HOME: C:\Users\Colin\AppData\Roaming\npm\node_modules\ant\ant
PATH: ...;%ANT_HOME%\bin;%PATH%\tools;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin;%JRE_HOME%\bin

Does anybody have a clue as to what could be causing this issue? Thank you

like image 712
user36388 Avatar asked Mar 19 '14 23:03

user36388


2 Answers

The main issue is that ant < 1.9.0 does not support Java 8. See the accepted answer here:
javac1.8 class not found

If it's inconvenient to change the version of ant used, using Java 6 or 7 will work.

like image 174
Daniel Schuler Avatar answered Nov 18 '22 02:11

Daniel Schuler


This worked for me, set compiler="javac1.6" or compiler="javac.17".

Of course you must have java1.6/1.7 installed.

<target name="compile">
    <javac srcdir="src" destdir="build/classes" source="1.6" target="1.6" compiler="javac1.6">
        <classpath>
            <fileset dir="lib">
                <include name="*.jar" />
            </fileset>
        </classpath>
    </javac>
like image 44
Alvaro Avatar answered Nov 18 '22 04:11

Alvaro