編譯android時,卡在tool-chain檢查的JDK

android編譯一開始就出現錯誤, 系統告知JDK不支援目前的編譯環境
怪了!之前還可以的耶…(因為我之前是裝sun jdk), 應該是後來有裝OpenJDK套件導致這個錯誤吧

Checking build tools versions…
************************************************************
You are attempting to build with an unsupported JDK.

You use OpenJDK but only Sun/Oracle JDK is supported.

************************************************************

由於我還保有原本安裝的sun JDK
所以只要在ubuntu的電腦上透過指令切換版本即可

In Ubuntu you don't have to uninstall one JDK to use another. 
You can have multiple Java versions installed and switch between them as you like. 
What matters is witch one is set as default.

Chose another Java loader:
sudo update-alternatives --config java

Chose another compiler (this is what you need):
sudo update-alternatives --config javac

Chose Java Web Start:
sudo update-alternatives --config javaws 

備註:

之前在ubuntu10.x版本時, 要編譯Android的環境設置
只要透過 apt-get install sun-java6-jdk 即可安裝, 現在再輸入指令已經找不到了
Ubuntu11.x之後版本, 要透過手動安裝Sun JDK…

建議安裝sun的jdk
教學文: 中文, 原文

1.去Oracle下載頁面
2.選"Java SE 6", 再選"Java SE Development Kit 6u45" (可能需註冊)
3.下載後的安裝指令:
//Make the downloaded binaries executable.
chmod u+x jdk-6u45-linux-x64.bin

//Extract it
./jdk-6u45-linux-x64.bin

//The usr/lib/jvm is the default installation directory of the Java JDK and the Java JRE
sudo mkdir -p /usr/lib/jvm
sudo mv jdk1.6.0_45 /usr/lib/jvm/

//Inform Ubuntu where your Java installation is located.
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_45/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_45/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javah" "javah" "/usr/lib/jvm/jdk1.6.0_45/bin/javah" 1
sudo update-alternatives --install "/usr/bin/javap" "javap" "/usr/lib/jvm/jdk1.6.0_45/bin/javap" 1
sudo update-alternatives --install "/usr/bin/javadoc" "javadoc" "/usr/lib/jvm/jdk1.6.0_45/bin/javadoc" 1
sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.6.0_45/bin/jar" 1

//Select your default Java installation & Inform Ubuntu
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javah
sudo update-alternatives --config javap
sudo update-alternatives --config javadoc
sudo update-alternatives --config jar

發表迴響