Configure Cordova for Android Error

I’m going through the installation tutorial and get the following error when I try to add android:

cordova platform add android
Checking Android requirements…
[Error: Please install Android target 17 (the Android 4.2 SDK). Make sure you have the latest Android tools installed as well. Run android from your command-line to install/update any missing SDKs or tools.]

I installed the SDK from http://developer.android.com/sdk/index.html

Is this the right version? Is the SDK not well past version 17 already?

When you install the sdk you have to open de Android SDK Manager, in the terminal with the “android” command, then you need to install the target 17, if you already do that maybe your PATH is not pointing to the right location of your SDK.

Thanks, I’ve installed all of API 17 using the android command and its manager window. The path to the SDK looks to be working as well.

Here is what I get now:

cordova platform add android
Checking Android requirements…
Creating android project…
[Error: An error occured during creation of android sub-project.
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
]

I then set the JAVA_HOME path in my bash_profile to:

export JAVA_HOME=/usr/libexec/java_home

Then restarted the terminal, then tried again and got the following result:

cordova platform add android
Checking Android requirements…
[Error: The command android failed. Make sure you have the latest Android SDK installed, and the android command (inside the tools/ folder) added to your path. Output: ]

Also, when I try the android command again I get:

android
Unable to locate an executable at “/usr/libexec/java_home/bin/java” (-1)
Unable to locate an executable at “/usr/libexec/java_home/bin/java” (-1)
Unable to locate an executable at “/usr/libexec/java_home/bin/java” (-1)

Then when I comment out the JAVA_HOME path from my bash_profile and restart the terminal the whole series of steps list above is required again, without success.

Is there something wrong with the Java SDK installed on my machine or the path?

I’ve installed the latest Apple update for Java, here is what the terminal now says:

java -version
java version "1.7.0_04"
Java™ SE Runtime Environment (build 1.7.0_04-b21)
Java HotSpot™ 64-Bit Server VM (build 23.0-b21, mixed mode)

After that I still have the following result:

cordova platform add android
Checking Android requirements…
Creating android project…
[Error: An error occured during creation of android sub-project.
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
]

Looking around there seems to be huge confusion on how to activate Java on OS X. Do I now also need to download and install the Oracle Java package from the following link?

http://www.java.com/en/download/mac_download.jsp

At this point I do not have a Java Control Panel and my machine has 1.6.0.jdk at the following location:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk

I’d like to finish this arduous task of getting Java working. If I can get some clear instructions I’m ready to proceed…

try export PATH=$PATH:/Android SDK/platform-tools:/Android SDK/tools

I’ve been using the following, where the … is the rest of the path into the adt-bundle:

export PATH=$PATH:/Users/…/adt-bundle/sdk/platform_tools:/Users/…/adt-bundle/sdk/tools

This is the complete path starting from the Mac HD which is similar to what I do for other tools like MongoDB. So then it is not a Java issue?

Happy to say that this problem is solved, discovered that my JAVA_HOME needed to be set to:

export JAVA_HOME=/usr/libexec/java_home -v 1.7

I needed to tell OS X where to look specifically as there is no more Java Control Panel, the issue is generally Apple and the endless Java headaches on OS X. It also was not necessary to download more Java Junk from Oracle.

Glad you got it fixed. Which version of OS X are you on, maybe I can add something like that to the docs.

I’m on OS X 10.7.5 with the latest Java update from Apple and no extra Oracle Java downloads.

Getting through the installation section of the tutorial was quite involved. There are many things to take care of on the Android side and really not any very clear info out there.

Just a suggestion but it might be useful to gather some aside links and short descriptions of the kind of things that might be encountered per platform, which the present installation section kinda wings over. Maybe an aside page in a FAQ format with links for topics.

Yea, I agree, it’s a pain in the ass :smile:

One thing we are eventually going to have is some kind of web-based dev/testing service which means no installation needed. That will probably be part of our business behind Ionic.

Sounds very good and I’m looking forward to learning more :smile:

I’ll carry on through the rest of the tutorial next. One of my goals once that is done is to see if I can have a small D3.js sample running in an Iconic app then also the HTML5 canvas element. Are there already graphic capabilities in any of the Iconic components?

Awesome. No graphic stuff built in beyond DOM nodes that we use, so you’d want to do that yourself. However, we’d love to have a contributed D3 example, so let us know if you’d like to share!

When I try to set JAVA_HOME as above, I get the following errors:

bash: export: /usr/libexec/java_home': not a valid identifier bash: export:-v’: not a valid identifier
bash: export: `1.7’: not a valid identifier

Did you get these errors as well?

i got this error as well. any tips/suggestions? trying to check my app on android platform. i have the latest mac os software, version 10.9.2 and was asked to download the Java update when first tried to add android platform to project.

You have to execute the java_home program and then assign the results:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)

Maybe the original poster used back-ticks and they did not show in his post.

Thanks for the tip, dude. :blush: