由于 Java 版本不正确导致 Android 构建错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13015899/
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
Android build error due to incorrect java version
提问by fadedreamz
I am currently trying to build Android just for learning purpose. But I am facing strange error -
我目前正在尝试仅出于学习目的构建 Android。但我面临着奇怪的错误 -
You are attempting to build with the incorrect version of java. Your version is: java version "1.7.0_07". The correct version is: Java SE 1.6.
您正在尝试使用不正确的 java 版本进行构建。您的版本是:java 版本“1.7.0_07”。正确的版本是:Java SE 1.6。
my java - version gives me
我的 java - 版本给了我
java version "1.7.0_07" Java(TM) SE Runtime Environment (build 1.7.0_07-b10) Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
java 版本“1.7.0_07”Java(TM) SE 运行时环境(构建 1.7.0_07-b10)Java HotSpot(TM) 64 位服务器 VM(构建 23.3-b01,混合模式)
any Idea what went wrong? regards,
任何想法出了什么问题?问候,
采纳答案by anz
Open jdk is not supported for android build. Try using sun jdk instead. You can install sun jdk by these commands:
android 版本不支持 Open jdk。尝试改用 sun jdk。您可以通过以下命令安装 sun jdk:
add-apt-repository "deb http://archive.canonical.com/ lucid partner"
apt-get update
apt-get install sun-java6-jdk
If the above command does not work(fails to download jdk), use the following commands instead:
如果上述命令不起作用(无法下载jdk),请改用以下命令:
add-apt-repository ppa:ferramroberto/java
apt-get update
apt-get install sun-java6-jdk
回答by Swapnil Kale
1.) If you've already installed OpenJDK . Remove it by running this command:
sudo apt-get purge openjdk*
1.) 如果您已经安装了 OpenJDK 。通过运行以下命令将其删除:
sudo apt-get purge openjdk*
2.) Then:
2.) 然后:
sudo add-apt-repository ppa:webupd8team/java
Then update:
然后更新:
sudo apt-get update
3.) Select which version you want To install Oracle Java 8:
3.) 选择要安装 Oracle Java 8 的版本:
sudo apt-get install oracle-java8-installer
To install Oracle Java 7:
要安装 Oracle Java 7:
sudo apt-get install oracle-java7-installer
To install the Java 6:
要安装 Java 6:
sudo apt-get install oracle-java6-installer
回答by user1770626
After upgrade Ubuntu 12.04 to 12.10 - just export path before build Android e.g:
将 Ubuntu 12.04 升级到 12.10 后 - 只需在构建 Android 之前导出路径,例如:
export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin/:$PATH
导出路径=/usr/lib/jvm/java-6-openjdk-amd64/bin/:$PATH
回答by dymmeh
In Eclipse.. Goto Window -> Preferences.. from there Expand the "Java" group. Click "Compiler". From there set the compiler compliance level to 1.6 and all other settings (if not already set to use the default compliance level) to 1.6
在 Eclipse.. Goto Window -> Preferences.. 从那里展开“Java”组。单击“编译器”。从那里将编译器合规级别设置为 1.6,并将所有其他设置(如果尚未设置为使用默认合规级别)为 1.6
回答by Barak
Exactly what the message says... Android requires Java 1.5 or 1.6... You are using 1.7
正是消息所说的……Android 需要 Java 1.5 或 1.6……您正在使用 1.7
Install and use Java 1.5 or 1.6.
安装并使用 Java 1.5 或 1.6。