I 'm trying to create a new project with phonegap3 :-
I set up the dev environment that include
node.js
Ant
Android SDK
and they all updated to the last versions
after creating the project , I get the directory for project:
EX :
phonegap create HelloWorld com.example.hello HelloWorld
but the main problem that I can't add the android platform to it
with the 3 comands as follow :-
trying to "phonegap add platform android"/"phonegap build android"/"phonegap run android"
I also installed throw the node the "cordova" and the same problem exists when I replace the phonegap with cordova !
Users\koko\test\www>phonegap build android
[ponegap] detecting Android SDK environment...
[ponegap] using the local environment
[onegap] adding the Android platform...
[error] An error occured during creation of android sub-project.
Users\koko\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at C:\Users\koko\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js:87:29
at _rejected (C:\Users\koko\.cordova\lib\android\cordova
.........
at process._tickCallback (node.js:415:13)
I also uninstall the node and re-download it and the problem still exists !
I viewed many questions with people around this issue but I don't know where exactly the error !
I wish to see the project running inside the emulator !
It seems, that cordova failed to execute following command in shell:
>android list target
Why don't you try to execute it manually? It may produce more information about this problem.
Didn't you forget to add following folders to your PATH?
android-sdk/tools
android-sdk/platform-tools
EDIT:
The latest android SDK has different folder structure. note the "sdk" folder.
android-sdk/sdk/tools
android-sdk/sdk/platform-tools
Make sure, you have set the following system variables:
ANT_HOME = path to ant files
JAVA_HOME = path to java JDK (NOT JRE!!)
ANDROID_HOME = path to android sdk
After that, you have to add
%ANT_HOME%\bin
%JAVA_HOME%\bin
%ANDROID_HOME%\bin
to your PATH variable.
If it still doesnt work, make sure you have the Google USB Driver installed (this took me hours to find and fix -.-)
Related
I've had this problem when build a android app with cordova command:
cordova build android
D:\Desenvolvimento\ionicapps\AppBelle>cordova build android Running command: "C:\Program Files\nodejs\node.exe"
D:\Desenvolvimento\ionicapps \AppBelle\hooks\after_prepare\010_add_platform_class.js D:\Desenvolvimento\ionic apps\AppBelle add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe" D:\Desenvolvimento\ionicapps \AppBelle\hooks\after_prepare\020_remove_sass_from_platforms.js D:\Desenvolvimen to\ionicapps\AppBelle
Running command: D:\Desenvolvimento\ionicapps\AppBelle\platforms\android\cordova \build.bat [Error: Android SDK not found. Make sure that it is installed. If it is not at t he default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms:
Error: D:\Desenvolvimento\ionicapps\AppBell e\platforms\android\cordova\build.bat: Command failed with exit code 2 You may not have the required environment or OS to build this project
Error: D:\Desenvolvimento\ionicapps\AppBelle\platforms\android\cordova\build.bat : Command failed with exit code 2 at ChildProcess.whenDone (C:\Users\Victor\AppData\Roaming\npm\node_modules\c ordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5)
D:\Desenvolvimento\ionicapps\AppBelle>echo %ANDROID_HOME% C:\Users\Victor\AppData\Local\Android\sdk\
Above I show location of env var ANDROID_HOME . I don't know what to do.
Help me, please.
Thanks
I'm learning Ionic (based on Cordova) these days, and I came to this similar problems in Mac os too when execute ionic build android, with similar error msg below:
Running command:/Users/ngloom/code/workspace/myWork/platforms/android/cordova/build
[Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.]
and the msg still exist after i setting the ANDROID_HOME environment, upgrade the sdk tools, finally i have to look into the check_reqs.js which throw the error and i found that the js is based on the cmd output by android list targets, and finally I found the android is owned by root (very likely that the android is installed by sudo brew before) and only error returned when executing by my user.
So I change the owner of android and everything works !
I post my solution here as a solution backup, hoping to help the guys in case like me :)
Unfortunately this can be a bug caused by upgrading android SDK versions. In general look for for different reasons:
First if you have to set the ANDROID_HOME environment variable. (according to your OS - In windows , right click your PC icon "MY PC", --> properties -> Advanced system settings -> Environment Variables" and set ANDROID_HOME variable and edit PATH variable to your path to your android SDK, tools & platform tools.
Secound try the "android" command in command tool, if android sdk couldn't open it cause a problem to build your app. I got this error:
The "android" command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use
tools\bin\sdkmanager.bat and tools\bin\avdmanager.bat
to solve it, you should downgrade your sdk using this links:
(Mac) https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
(Windows) https://dl.google.com/android/repository/tools_r25.2.3-windows.zip
and replace the zip file with your "tools" folder in your android SDK, It will work fine after trying "android" command and building app command in cordova and ionic frameworks.
Digging the reason: (In my case)
Why failing android command is causing this problem?
part of the cordova or ionic configuration in js files are using android command to "VERIFY" your "ANDROID_HOME" and "PATH" environment variables to operate building your app, and in case of any failure accessing to Android sdk via command access, system tells you "Android SDK" is not found. Recently, in new version android command is no longer accessible and is causing issues for any operation whom used this command. :/
Hope it works for you, It took a time for me to figure out solving this issue and don't forget to (+1) if it helped you!
Setting environmental variables use this to set up the path to tools and platform tools and update SDK for the android version that you are trying to build and make sure weather its Ionic or cordova application and then try once
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...
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\q.j
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\q.j
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)
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.
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
FINAL SOLUTION
Finally I re-installed JDK and Android SDK and now everything works even it is still mystery to me.
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.
ANT_HOME, JAVA_HOME and ANDROID_HOME
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
developer.android.com/tools/devices/managing-avds-cmdline.html
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 http://spring.io/guides/gs/android/ + 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. https://github.com/phonegap/phonegap-cli/issues/77
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?
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.
in .bashrc try adding
export ANT_HOME="/usr/bin/ant"
export PATH="$PATH:$ANT_HOME/bin"
export HOME="/home/username"
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"
or try explicitly define the paths globally.
from the terminal I type:
export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/tools
export PATH=${PATH}:~/dev/adt-bundle-linux-x86_64-20140321/sdk/platform-tools
(rememebr to replace with your own sdk path)
If this doesn't work, try updating the sdk
Please Refer the Question
An error occurred while listing Android targets
and the Link
developer.android.com/tools/devices/managing-avds-cmdline.html
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 faced the Issue even after the Cordova check_reqs was working correctly without providing any error.But on adding a new platform this error was still being raised. The above method personaly resolved my issue.
I solved the problem giving full permission for my app folder
$ sudo chmod -R 777 myApp
After that, try again
$ cd myApp
$ ionic platform android
I've read this: Cordova and setting Android using command line
and that How to add android to cordova platform? PATH error? and generally speaking whole documentation. I've added both 'platform-tool' and 'tool' paths, installed android 4.4 and I'm still getting the error from the tittle when I'm trying cordova platform add android to my current project ( in cmd and in netbeans ).
The only thing I haven't done is adding java and ant to path. I was trying with ;%JAVA_HOME%\bin;%ANT_HOME%\bin but still those commands aren't recognizable.
What else can I do?
EDIT:
I've added java and ant to PATH. This is what I get in cmd:
C:\xampp\htdocs\mobile_maps>cordova platform add android
[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 pa
th. Output: ]
Second EDIT:
i also get 'xcopy' is not recognized as an internal or external command even though I've added %SystemRoot%\System32; %SystemRoot%; %SystemRoot%\System32\wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0 . I really don't know what else I can do..
usually this happens when:
1. Java is not installed
2. Java is not exported (no JAVA_HOME env variable) or paths are wrong
3. only 64bit version of Java is installed
to fix install 32bit support on your system.
and (as comments below) relog in Windows to environment changes take effect.
I'm trying to do phonegap build android and I have this message :
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. Path not found
Phonegap is looking for "C:\Documents and Settings\corbg\.cordova\lib\android\cordova\3.0.0\bin\create". There is nothing under the directory "3.0.0". I installed cordova like this npm install -g cordova.
I have the some problem when I run cordova platform add android.
Did I missing something?
In Windows machine you have to delete .cordova directory under
C:\Users\user_name\
I have face the same issue, then i corrected my application path, afterthat it is worked out for me.
If you are using win 7 then add the Android ADK path in
open the mycomputer -> Properties -> Change Settings-> Advanced -> Environment Variable -> User variable for ....-> path
add the Android ADK path here like as following
C:\AndroidDev\adt-bundle-windows-x86-20131030\sdk\tools; C:\AndroidDev\adt-bundle-windows-x86-20131030\sdk\platform-tools
also add JAVA_HOME and ANT_HOME.
- Abdul Jabbar
Did you set your PATH variable? Sometimes this error occurs in Windows when the PATH variable is not set correctly to access "java" and "ant" exes. If you want to test if they are correctly set, you can simply execute both (from any folder in your command line):
> java
or
> ant
and both programs should be found.
It was a problem with my proxy. Cordova create a .cordova directory and try to download something on the internet. The download did not work. Next time, it check if there is a .cordova directory. It don't try to redownload something because the directory exist and it show the error.
I removed the .cordova directory and I solved my problems with proxy. Now, everythings works.
What solved the issue for me was having 2 directories on my PATH, the android platform-tools and tools.
In my pc those folders were at
C:\Program Files (x86)\Android\android-sdk\tools
C:\Program Files (x86)\Android\android-sdk\platform-tools
Also make sure you have the following environment variables
JAVA_HOME (C:\Program Files\Java\jdk1.7.0_51)
ANT_HOME (C:\Program Files\apache\apache-ant-1.9.3)
ANDROID_HOME (C:\Program Files (x86)\Android\android-sdk\platform-tools)
I removed the .cordova folder under my user folder but I'm not quite sure if that helped as well.
These links may help you
An error occured during creation of android sub-project
android' is not recognized as an internal or external command
I had the exact same problem for a different reason. I had an old version of ant (1.7.1). At least version 1.8.2 is needed for the build to work.
its either due to improper installation or no installation of ANT or JAVA. But moreover we need to add Android SDk and prepare Android Targets via SDK manager before going through this.
This is because you haven't installed ANT!
download it from here and install it step by step
https://ant.apache.org/manual/install.html
Then running the last command it will install the dependencies needed.