Cordoba add android platform does not work when listing Android goals

I am having problems when I want to add the Android platform to the phoneGap application. I received this message in my CLI when I run the corova platform add android command:

Checking Android requirements... (Error: An error occurred while listing Android targets)

I'm already trying to add my Android sdk location to a path variable.

Please help me !: D

I am working on 64-bit versions of Windows 7, I am installing the android API 17, 18 and 19 using the android SDK. I am in version 3.2 of phoneGap.

+72
android windows cordova
Dec 02 '13 at 8:28
source share
12 answers

To work, this cordova command needs to use some programs located in your sdk/tools directory. You also need to install apache ant .

Then you must add these directories to your system PATH variable:

Background:

  • Suppose you installed the Android SDK in the c:\sdk\android directory
  • you installed < Apache ant in the c:\tools\apache-ant directory

Then you must create two system variables:

  • ANDROID_HOME with c:\sdk\android value
  • ANT_HOME with a value of c:\tools\apache-ant

Finally, you must modify the PATH variable and add these two to the end of the PATH value:

 ;%PATH%\tools;%ANT_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools 

NOTE: for those using Linux, the instructions are slightly different.

Further documentation is available here .

+167
Dec 02 '13 at 16:29
source share

For the select few who prefer the Linux development environment

Requirements

First of all, you need a few things to get you started. These are: Android SDK and Apache Ant . Of course you will need the Java SDK (JDK).

To make the Android SDK work for all users, you need to modify the /etc/environment file and then restart the computer. But if you do not want this difficult path, follow me, think of yourself as the only PC user. And use the file /home/YOUR_USERNAME/.bashrc for editing.

Remember your home path once to prevent further long lines. Add this to your /home/YOUR_USERNAME/.bashrc :

 export HOME="/home/YOUR_USERNAME" 

Then we will use the notation $HOME if we want to say " /home/YOUR_USERNAME directory ".

Android SDK setup

Download the Android SDK archive and unzip it somewhere. Say in your home directory $HOME/adt-bundle/ .

Add these lines to your $HOME/.bashrc :

 export ANDROID_HOME="$HOME/android-bundle/sdk/tools" export ANDROID_PLATFORM_TOOLS="$HOME/android-bundle/sdk/platform-tools" export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH" 

Ant Tuning

As with the Android SDK, download the archive and unzip it to your home directory. Then add them to your .bashrc :

 export ANT_HOME="$HOME/ant" export PATH="$PATH:$ANT_HOME/bin" 

I installed one via apt-get , so this did not affect my .bashrc .

Apply Changes

For these changes to work, you must either work in a new terminal window (open after ), or run source ~/.bashrc to make the changes available in the current terminal window.

Completion

At the end you will receive:

  • Two directories in your home directory - ant and android-bundle
  • A few lines added to your .bashrc :

     export ANDROID_HOME="$HOME/android-bundle/sdk/tools" export ANDROID_PLATFORM_TOOLS="$HOME/android-bundle/sdk/platform-tools" export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH" export ANT_HOME="$HOME/ant" export PATH="$PATH:$ANT_HOME/bin" 
+42
Jan 15 '14 at 16:09
source share

Run the "android" command from the adt \ sdk \ tools folder and install the latest tools and SDK. Also make sure your PATH has the correct variables.

To do this, you will need ANT to install, JAVA JDK and Android SDK installed

JAVA_HOME (C: \ Program Files \ Java \ jdk)

ANT_HOME ({ant location} \ apache \ apache- ant)

ANDROID_HOME ({android sdk location} \ android-sdk)

Add them to your PATH variable, for example,% ANT_HOME% / bin;% ANDROID_HOME% \ tools;% ANDROID_HOME% \ platform-tools;% JAVA_HOME% \ bin

Close and reopen your cmd and run the command again.

Compatible with PhoneGap / Cordova Android Phone

+21
Feb 06 '14 at 20:47
source share

I'm not sure if this is your problem, but I came across similar errors when the cordon library cache is dirty with something damaged. To fix this, you just need to delete the cache cord, and it will be automatically refilled the next time you use the cord.

On OS X, this directory is ~ / .cordova. On Windows, I assume this is .cordova in your users home directory.

+4
Dec 02 '13 at 8:52
source share

Answer: "Everything is higher." However, as mentioned in the environment variables, follow these steps:

C: \ Users {YOUR_NAME} .cordova \ lib \ android \ cordova \ 3.5.0 \ framework edit the project.properties file and change target = android-19 to target = android-20.

Presumably, this will need to be changed for the next android sdk execution until this small problem is resolved.

+4
Jul 17 '14 at 19:39
source share

after a long struggle, having completed all of the above suggestions more than once with growing despair, I simply opened my cmd as an administrator. it worked. I think I'm just too used to sudo before I get this computer.

+2
Feb 05 '14 at 16:45
source share

For those who are faced with this problem, I am adding something extra that may be useful, in my case all the variables are correctly configured, and it is still unable to add the Android platform, and I really disabled my avast antivirus and layer! everything went smoothly, it happened that the antivirus blocked the creation of the platform.

It was also important to restart the computer .;)

Sincerely.

+2
Mar 31 '14 at 4:36
source share

I had the same problem, although the path variables were set exactly as instructed. After going through a few files, I finally decided. For me (Windows 64 Enterprise 64 bit) I had to change check_reqs.js and create.js from "C: \ Users \ .cordova \ lib \ android \ cordova \ 3.5.0 \ bin \ lib \" to include the absolute path for android.bat. My Android SDK runs under "C: \ Android \ android-sdk".

In check_reqs.js I changed

 child_process.exec('android list targets', function(err, stdout, stderr) { 

to

 child_process.exec('C:\\Android\\android-sdk\\tools\\android.bat list targets', function(err, stdout, stderr) { 

In create.js I changed the statement

 return exec('android update project --subprojects --path "' + projectPath + '" --target ' + target_api + ' --library "' + path.relative(projectPath, targetFrameworkDir) + '"'); 

to

 return exec('C:\\Android\\android-sdk\\tools\\android.bat update project --subprojects --path "' + projectPath + '" --target ' + target_api + ' --library "' + path.relative(projectPath, targetFrameworkDir) + '"'); 

Also don't forget those double "\\" in the absolute path

+2
May 27 '14 at 20:20
source share

I noticed a problem with Cygwin / Windows 7. The problem is related to several different ways: Cygwin and MS-DOS shells process .bat files.

During the "add platform" cordova calls "android":

 C:\Users\xxx\.cordova\lib\android\cordova\3.4.0\bin\lib\check_reqs.js 

Where he calls the "Android list targets" (line 73)

"android" should allow / xx / android-sdk / tools / android.bat or xx: \ android-sdk \ tools \ android.bat. (And, in fact, I can run "android" in the MS-DOS command shell, but not in the Cygwin shell. I need to add ".bat" there.)

An β€œandroid” without a β€œ.bat” does not work in the Cygwin shell because the android.exe file does not exist (only .bat). Changing line 73 to call "android.bat list targets" will solve your problem (or give a reasonable error message).

Another problem is running the cord in the MS-DOS shell instead of the Cygwin shell.

+1
Apr 28 '14 at 14:27
source share

We have a list of solutions, so I add my own. It was incomprehensible to me until I just tried. You should add% ANT_HOME% \ bin;% ANDROID_HOME% \ tools;% ANDROID_HOME% \ platform-tools to the USER PATH variable, not the system variable. The System PATH variable automatically combines the USER PATH variable and translates the variables into its value. Hope this helps someone. Postscript My OS - Win 7x64

0
Jun 13 '14 at 7:37
source share

This problem usually occurs because the PATH variable is not set for the Android SDK.

 export HOME="/home/yourname" export ANDROID_HOME="$HOME/android-bundle/sdk/tools" export ANDROID_PLATFORM_TOOLS="$HOME/android-bundle/sdk/platform-tools" export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH" export ANT_HOME="$HOME/ant" export PATH="$PATH:$ANT_HOME/bin" 
0
Sep 09 '14 at 11:27
source share

The accepted answer is good and matches the point.

I came across another page where the screenshots explained it very well.

You can refer http://bealers.com/2014/06/phonegap-android-development-environment-for-windows/

0
Nov 11 '14 at 13:21
source share



All Articles