cordova ubuntu: An error occurred while listing Android targets

android, cordova, ubuntu

Solution

Cordova has a script to check if all dependencies are present. Is is called when you run `cordova platform add android` but unfortunatly it's output is not displayed when it fails.

You can try to run it manually, it should be `$home/.cordova/lib/android/cordova/3.5.0/bin/check_reqs`

The normal output when everything's fine is "Looks like your environment fully supports cordova-android development!", oterwise it should display a clear message about what's missing.

Maybe your issue is that you havent't installed SDK platform for API 19 in android sdk manager (cordova 3.3 or 3.5 uses target sdk 19).

Update: Cordova 3.3 or 3.5 works on SDK 19 only (Android 4.4.2). The error logs does not mention clearly what platform version it is looking for. Typically error messages are:

Unable to add platform android. Please see console for more info.

or

[Error: An error occurred while listing Android targets]

This can also happen when `android` (sdk/tools) is not in path. I would have loved if the check-script have printed correct error message. BTW, created a PR for them.

Problem

I'm trying add the android platform to my cordova project, though I get the error: ``` $ cordova platform add android -d cordova library for "android" already exists. No need to download. Continuing. Checking if platform "android" passes minimum requirements... Checking Android requirements... cordova library for "android" already exists. No need to download. Continuing. Error: An error occurred while listing Android targets at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/lib/check_reqs.js:83:29 at _rejected (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:808:24) at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:834:30 at Promise.when (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:1079:31) at Promise.promise.promiseDispatch (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:752:41) at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:574:44 at flush (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:108:17) at process._tickCallback (node.js:415:13) ``` Without the `-d` it will be: ``` Checking Android requirements... [Error: An error occurred while listing Android targets] ``` I'm not sure what configuration I am missing. In my `~/.bashrc` file I have: ``` ### Java export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 export ANDROID_HOME=~/Code/adt-bundle-linux-x86-20131030/sdk/tools export ANDROID_PLATFORM_TOOLS=~/Code/adt-bundle-linux-x86-20131030/sdk/platform-tools export PATH=$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH ``` and I have ant installed: ``` $ ant -version Apache Ant(TM) version 1.8.2 compiled on December 3 2011 ``` What's missing? Why do i get the error `An error occurred while listing Android targets` when trying to add the android platform to the cordova project?

Original source

Related problems