I just picked up the latest version of the Android SDK and started trying to use it. Unlike almost everyone else coming up with this problem, I’m running Linux, namely Linux Mint 13. I’m currently trying to compile a Hello World program using ant, installed via
sudo apt-get install ant
and ran in the project folder:
ant debug
However, it fails utterly to compile, eventually spitting out an error to do with setting JAVA_HOME. I amended my ~/.bashrc file accordingly and restarted, but I still get the error:
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-7-openjdk-amd64/jre"
Total time: 1 second
jamie@jamie-ThinkPad-E525 ~/Downloads/adt-bundle-linux/sdk/tools/projects/new $ echo $JAVA_HOME
/usr/java/jdk1.7.0_05/
As you can see, it’s lying through its teeth.
I’ve found lots of references to this problem, but most people have either set their JAVA_HOME incorrectly, or set it to the JRE. Clearly, I have done neither.
I also amended my project folder’s ant.properties file, adding the line
java.home=/usr/java/jdk1.7.0_05/
to no avail.
Has anyone else experienced/solved this problem, or got any ideas? Thanks.
The chances are that
antis telling the truth and that the environment variable is not set. The chances are that:Anyway, you can verify this by running
exportin the shell before to run theantcommand … and looking to see if theJAVA_HOMEvariable is listed.Hints:
1) This is wrong:
That only creates a local shell variable, and local shell variables are NOT passed to child process (like the
antcommand). It should be:2) Try running this:
3) Adding
java.home=/usr/java/jdk1.7.0_05/to ant.properties won’t help. Ant expects the setting in an environment variable.4) Computer programs don’t lie. They tell the truth as they see it. Or to be more accurate, the whole notion of lying and telling the truth is meaningless unless the agent is capable of intention. But the point is that if you start to suspect computer programs of trying to deceive you, you are going to have a hard time debugging things.
(OK, you were joking. But many people faced with a troubleshooting problem take a similarly unproductive approach; e.g. assuming that every tricky Java problem is evidence that the compiler / language / runtime is broken. IMO – it is worth reminding people that this kind of thinking can be very unhelpful ….)