Cordova for android: An error occurred while listening android targets

I have read all the questions for the same problems and I have tried everything but nothing is working for me when I try to add android platform for cordova.

c:\Apps\fapp>cordova platform add android
Creating android project...

                    throw e;
Error: An error occurred while listing Android targets
    at C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\lib\check_reqs.js:
    at _rejected (C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_mo
    at C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.j
    at Promise.when (C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node
    at Promise.promise.promiseDispatch (C:\Users\Andrej\.cordova\lib\android\cor
    at C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.j
    at flush (C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_module
    at process._tickCallback (node.js:415:13)
Error: cmd: Command failed with exit code 8
    at ChildProcess.whenDone (C:\Users\Andrej\AppData\Roaming\npm\node_modules\c
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
  • Project is created using cordova create fapp com.fapp Fapp
  • System is windows 8
  • ANT, JAVA (JDK 1.7.0_51 and JRE7), Android SDKs are installed from (17-19.0.3) and Android APIs (17-19)
  • All environment variables for JAVA, ANDROID and ANT are set as well as path to bin for all of them into Path variable.

I really tried everything but keeps throwing this problem.

  • Fingerprint Scanner using Camera
  • how to access to a specific element of every grid view item
  • Good approach to manually retry requests in Retrofit Android
  • Android intent filter: associate app with file extension
  • Android Manifest - “Has No Default Constructor” With Activity/Runnable Class
  • What is a non-embedded activity and why doesn't android:fitsSystemWindows work in it?
  • EDIT:

    • Answer here did not help:
      cordova ubuntu: An error occurred while listing Android targets
    • Permissions are set to Everyone full control and same issue


    • Finally I re-installed JDK and Android SDK and now everything works even it is still mystery to me.

    Related posts:

    Eclipse - Errors running builder 'Android Package Builder'
    Android- Google map v2 Draw circle
    AlertDialog style buttons for an Activity
    Appwidget size calculation
    How to get the processor number on android
    Admob interstial loadAd function too slow
  • Android youtube API play two or more Youtube players in one main activity
  • How to check programmatically if an application is installed or not in Android?
  • Navigation drawer - Disable click through on items behind the drawer
  • Libgdx weird modelling - depth error?
  • Android Studio GPU monitor will not work for OpenGLES2
  • WebRTC on Android
  • 5 Solutions collect form web for “Cordova for android: An error occurred while listening android targets”

    I had the same issue and solved it by setting the following environment variables:

    • %JAVA_HOME% points to the root of your java installation (not the bin directory). In my computer it is: C:\Program Files\Java\jdk1.8.0. To test that it is configured correctly, open a new terminal and type javac. It should run the java compiler and shouldn’t complain that it doesn’t know the command. Please note that environment variables are only set when opening a new terminal (at least on windows) so every time you change something you have to open a new terminal.

    • %ANT_HOME% point to the root of where you’ve installed Apache ant. In my computer it is: C:\Users\User\apache-ant-1.9.3. Test it by running the ant command. It shouldn’t complain that the ant command is unknown to your machine. Remember to open a new terminal after setting the path and then try running ant.

    • %ANDROID_HOME% points to where you have installed your android SDK. For example: C:\Users\User\android\sdk. Then try typing emulator to make sure it is installed correctly.

    When all of these variables are set, you can use them in the PATH environment variable :

    %PATH% contains the following entries: %ANT_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin

    On windows 8 you can configure path and variables by right clicking on the start button, choosing system, and then advanced system settings and clicking on environment variables button. Remember to define the above environment variables above PATH. I defined everything in the user variables and it works just fine.

    -Possible solution for those who encounter this error

    I had this error and it did relate to the path variables. I thought I had everything set correctly, but I was missing a portion.

    First check by typing the command android into command line. If the SDK isn’t opened you have not set the variables and/or path correctly.

    You should have 3 (or 4 if you have separate android ones) variables.


    ANDROID_HOME should point to the sdk. If you (like I did) downloaded the bundle which includes eclipse, you need to have this variable point to the sdk folder inside the android bundle folder, not the android bundle folder itself (eg. C:\Dev\adt-bundle-windows\sdk)

    You need to add %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to your path. Along with the link to the ANT bin folder and jdk bin.

    I strongly urge you to triple check that all variables are correctly set AND that all four parts are added to the path.

    Please Refer the Question

    An error occurred while listing Android targets

    and the Link

    Most probably the path variable pointing to this android was wrong.
    I had used %ANDROID_HOME% as variable and scaled the same to path variables %ANDROID_HOME%\SDK\TOOLS. This method doesn’t work. Experimentally resolved by directly pointing to the Tools and Platform Tools.

    Just based on what I did and it worked for me. Hope You get the Issue resolved.

    I had the same issue with version 3.5.0.

    The problem is, that the error message from the script check_reqs located in C:\Users\{yourUserName}\.cordova\lib\android\cordova\3.5.0\bin, is not forwarded correctly.

    I run the mentioned script manually and got the following error message:

    [Error: Please install Android target 19 (the Android newest 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.]

    So basically to solve this issue you have to install the latest Android SDK.

    This link + running cmd as an administrator solved that issue for me.

    This confirms Michael Brooks’ assumption that this issue has to do with permissions settings on the Windows OS.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.