尝试使用 ionic 构建 Android Emulator 失败..“找不到类:javac1.8”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22520093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trying to build Android Emulator with ionic fails.. "Class not found: javac1.8"
提问by user36388
I'm trying to emulate android using ionic framework's "ionic emulate android" command.
我正在尝试使用 ionic 框架的“ionic emulate android”命令来模拟 android。
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 和 JDK;
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
有没有人知道可能导致此问题的原因?谢谢
采纳答案by Daniel Schuler
The main issue is that ant < 1.9.0 does not support Java 8. See the accepted answer here:
javac1.8 class not found
主要问题是 ant < 1.9.0 不支持 Java 8。请参阅此处接受的答案:
javac1.8 class not found
If it's inconvenient to change the version of ant used, using Java 6 or 7 will work.
如果不方便更改使用的 ant 版本,则使用 Java 6 或 7 即可。
回答by Alvaro
This worked for me, set compiler="javac1.6"
or compiler="javac.17"
.
这对我有用, setcompiler="javac1.6"
或compiler="javac.17"
.
Of course you must have java1.6/1.7 installed.
当然你必须安装java1.6/1.7。
<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>