Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build android project with openjdk on Ubuntu?

I found this Is Sun Java really necessary for using Android SDK on Ubuntu 10.10? I prefer OpenJDK but I can't build android project on Ubuntu. When I try:

$ ant debug

I got:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar

...

BUILD FAILED
/home/kuba/projects/Android/android-sdk-linux/tools/ant/build.xml:651: The following error occurred while executing this line:
/home/kuba/projects/Android/android-sdk-linux/tools/ant/build.xml:672: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"

I have java version:

$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.13) (6b20-1.9.13-0ubuntu1~10.10.1)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)
like image 611
jcubic Avatar asked Jun 24 '12 14:06

jcubic


People also ask

Can I use OpenJDK for Android development?

OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

Is Ubuntu good for Android development?

For developers looking to build Android apps, Ubuntu is the ideal platform in conjunction with Android Studio – the official Android development environment.

Can I use JDK 11 for Android studio?

Up to Android Studio 3.5 beta 2 one could use JDK11 for compiling project by configuring it in Project Structure -> SDK Location -> JDK Location. This way Android Studio is run under bundled JDK8 but Gradle is using selected JDK11. Starting from Android Studio 3.5 beta 3 this setup is no longer supported.

Can we install Android Studio on Ubuntu?

To install Android Studio we can visit the Ubuntu Software Centre and search for Android Studio. Once we found the software easily click on the install button. We will get a password prompt to confirm the installation process.


1 Answers

Make sure you have the openjdk JDK installed. By default you probably only have the JRE installed. If you open Synaptic, search for openjdk and then you'll see both the JDK and the JRE. Select the JDK package and install. I think the actual packagename is openjdk-6-jdk.

or use the commandline

# sudo apt-get install openjdk-6-jdk
like image 120
stuckless Avatar answered Sep 19 '22 07:09

stuckless