Cordoba for Android: An error occurred while listening to Android targets

I read all the questions on the same issues, and I tried everything, but nothing works for me when I try to add the android platform for the cordova.

c:\Apps\fapp>cordova platform add android Creating android project... C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.js:126 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: 87:29 at _rejected (C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_mo dules\q\q.js:808:24) at C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\qj s:834:30 at Promise.when (C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node _modules\q\q.js:1079:31) at Promise.promise.promiseDispatch (C:\Users\Andrej\.cordova\lib\android\cor dova\3.4.0\bin\node_modules\q\q.js:752:41) at C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\qj s:574:44 at flush (C:\Users\Andrej\.cordova\lib\android\cordova\3.4.0\bin\node_module s\q\q.js:108:17) 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 ordova\src\superspawn.js:112:23) 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) 
  • The project is created using the cord create fapp com.fapp Fapp
  • System is windows 8
  • ANT, JAVA (JDK 1.7.0_51 and JRE7), Android SDK installed from (17-19.0.3) and Android API (17-19)
  • All environment variables for JAVA, ANDROID and ANT are set in the same way as the bin path for all of them to the Path variable.

I really tried everything, but keep throwing this problem.

EDIT:

FINAL DECISION

  • Finally, I installed the JDK and Android SDK again, and now everything works, even for me it still remains a mystery.
+6
source share
5 answers

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

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

  • %ANT_HOME% specify the root of where you installed Apache ant. On my computer, this is: C:\Users\User\apache-ant-1.9.3 . Test it by running the ant command. You should not 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% indicates where you installed your Android SDK. For example: C:\Users\User\android\sdk . Then try entering emulator to make sure it is installed correctly.

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

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

In windows 8, you can configure the path and variables by right-clicking on the start button, selecting a system, then advanced system settings and clicking the environment variable button. Remember to define the above environment variables above PATH. I defined everything in user variables and it works great.

+16
source

- a useful solution for those who encounter this error

I had this error and it related to path variables. I thought everything was set up correctly, but I didn’t have a part.

First check by entering the android command on the command line. If the SDK is not open, you did not set the variables and / or the path correctly.

You should have 3 (or 4 if you have separate androids).

 ANT_HOME, JAVA_HOME and ANDROID_HOME 

ANDROID_HOME must point to sdk. If you (for example, me) downloaded a package that includes eclipse, you need this variable to point to the sdk folder inside the Android package folder, and not to the android folder itself (for example, C: \ Dev \ adt-bundle-windows \ SDK )

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

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

+5
source

Please refer to the question

An error occurred while displaying Android goals

and developer.android.com/tools/devices/managing-avds-cmdline.html link

Most likely, the path variable pointing to this android was wrong. I used% ANDROID_HOME% as a variable and scaled the same with the path variables% ANDROID_HOME% \ SDK \ TOOLS. This method does not work. Experimentally resolved by direct reference to Tools and platform tools.

Just based on what I did, and it worked for me. Hope the problem is resolved.

+1
source

I had the same problem 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 redirected correctly.

I run the specified script manually and received the following error message:

[Error: set Android target 19 (new SDK for Android). Make sure you have the latest Android tools installed. Run "android" from the command line to install / update the missing SDKs or tools.]

So, to solve this problem, you need to install the latest Android SDK.

0
source

This link is http://spring.io/guides/gs/android/ + launching cmd, as the administrator solved this problem for me.

This confirms Michael Brooks' suggestion that this problem is related to permission settings in Windows. https://github.com/phonegap/phonegap-cli/issues/77

0
source

All Articles