When installing PhoneGap via nodeJS i got an error when trying to run my app (installing phonegap and creating the app worked):
C:\Users\arko\my-app>phonegap run android
[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.
C:\Users\arko\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
at C:\Users\arko\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js:47
:27
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Socket.<anonymous> (child_process.js:956:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
So I noticed I never had ANT installed, so I did. I followed this tutorial: http://cleancodedevelopment-qualityseal.blogspot.nl/2012/11/how-to-install-phonegap-for-android.html and done everything it said.
The part it says you have to add stuff to the Path variable, it said just add this: %ANT_HOME%\bin; however my Path ended with this: C:\Program Files\Windows Live\Shared - so I added this to it: ;%ANT_HOME%\bin;
Tried to run the android app again, and got the same error. I ran it with this command:
phonegap run android
What am I doing wrong?
Thanks!
Probably you have a new version of cordova, i saw that in a partner machine was installed the cordova version 3.5.0 and in my machine it was installed the 3.4.0 version, maybe the ant version is incompatible with the new version of cordova (He and i has the ant version 1.9.4) .
Try install a old version of cordova with this command in the node.js console:
npm install -g cordova#3.4.0-0.1.0
and run the command again.
Other cause: Verify that your Path Variables are configured correctly..
My english is not pretty good, but i hope help you to solve the problem.
Variable: ANDROID_HOME Value: C:\Development\adt-bundle\sdk
Variable: ANT_HOME Value: C:\Development\apache-ant-1.9.2
Variable: JAVA_HOME Value: C:\Program Files\Java\jdk1.6.0_45
then define system paths
%JAVA_HOME%\bin;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
reboot your computer
Cannot get ant installed properly for phonegap using eclipse and windows 8
Set the path for ant in your system variables, and use that variable path in your user variables.
After setting both, restart your computer so they take effect.
User variables:
PATH = %ANT_HOME%/bin
System variables:
ANT_HOME = c:\your directory
such as
ANT_HOME = C:\ant
Double check what you set ANT_HOME to, you can do that by opening a "command prompt" (Start -> Run -> CMD) and type echo %ANT_HOME%
Check if this is the correct directory that you have ANT installed into, otherwise set it. (The URL you linked to tells you how).
You can verify the ANT "installation" by typeing ant -version in a "command prompt" window.
¿Did you create JAVA_HOME and ANT_HOME variables? ¿Did you also add to the PATH?
Instead of creating the ant variable ANT_HOME, just insert the absolute path in your windows system variable PATH like this:
c:\yourDirectory\ant\bin;
Then it should work/run fine!
Related
I have all set up .
I have installed android sdk api 24 and all the necessary tools. I have also tried reinstalling ionic and cordova but it does not work.
This is the error log:
D:\Coursera\Course 4\myapp1\public>ionic platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.ionicframework.myapp1409522
Name: myapp1
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
Installing "cordova-plugin-console" for android
Failed to install 'cordova-plugin-console':Error: cmd: Command failed with exit
code ENOENT
at ChildProcess.whenDone (C:\Users\Sahib\AppData\Roaming\npm\node_modules\co
rdova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitOne (events.js:96:13)
at ChildProcess.emit (events.js:188:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: cmd: Command failed with exit code ENOENT
I think you are not adding environment variable.
Please go through following steps :
Windows users developing for Android: You'll want to make sure you have the following installed and set up.
NOTE: Whenever you make changes to the PATH, or any other environment variable, you'll need to restart or open a new tab in your shell program for the PATH change to take effect.
Java JDK
Install the most recent Java JDK (NOT just the JRE).
Next, create an environment variable for JAVA_HOME pointing to the root folder where the Java JDK was installed. So, if you installed the JDK into C:\Program Files\Java\jdk7, set JAVA_HOME to be this path. After that, add the JDK's bin directory to the PATH variable as well. Following the previous assumption, this should be either %JAVA_HOME%\bin or the full path C:\Program Files\Java\jdk7\bin
Apache Ant
To install Ant, download a zip from here, extract it, move the first folder in the zip to a safe place, and update your PATH to include the bin folder in that folder. For example, if you moved the Ant folder to c:/, you'd want to add this to your PATH: C:\apache-ant-1.9.2\bin.
Android SDK
Installing the Android SDK is also necessary. The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android.
Cordova requires the ANDROID_HOME environment variable to be set. This should point to the [ANDROID_SDK_DIR]\android-sdk directory (for example c:\android\android-sdk).
Next, update your PATH to include the tools/ and platform-tools/ folder in that folder. So, using ANDROID_HOME, you would add both %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools.
For more please check here and here.
Hope this will help you !!
My final solution was to add the Environmentvariable:
_JAVA_OPTIONS: -Xmx512m
You may vary the 512m by your needs.
Most probably, you need to add "C:\Windows\System32" to your path variable.
Error at cmd when building ionic project with android
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: cmd: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\Hasan\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess.handle.onexit (childprocess.js:1087:5)
so what is the problem what must I do to fix it ?? I have android sdk on my pc, and m working on windows 10, I have installed nodejs. Can anybody help me
Go to Advanced System Settings, then go to Environment Variables and select PATH variable to edit. There you have to append path to platform tools and tools of sdk, for example like this ;C:\Development\android-sdk\platform-tools;C:\Development\android-sdk\tools
Now go to cmd and run android, if that does not open android sdk manager, then it means path has not been set correctly or cmd is not recognizing enviroment variable updtes, in that case restart your computer and it will work.
Go to Advanced System Settings, then go to Environment Variables
Then add new Variables with name "ANDROID_HOME" and the value will be you SDK path like
C:\Android\sdk
Make sure to restart visual studio before run again
it will fix
Creating android project... Error:
C:\Users\user1.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\create.bat:
Command failed with exit code ENOENT at ChildProcess.whenDone
(C:\Users\user1\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:95:17) at
Process.ChildProcess._handle.onexit (child_process.js:807:12)
The Path environment variable is set as :
C:\ProgramData\Oracle\Java\javapath;%SystemRoot%;%SystemRoot%\system32;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\Program
Files\TortoiseSVN\bin;%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANT_HOME%\bin;C:\Program
Files\nodejs\
where JAVA_HOME is :C:\Program Files\Java\jdk1.8.0_25 ANDROID_HOME is
: D:\Softwares\AndroidSDK\sdk\sdk ANDROID_SWT is:
D:\Softwares\AndroidSDK\sdk\sdk\tools\lib\x86_64 ANT_HOME: C:\Program
Files\apache-ant-1.9.4
I have tried with installing jdk 7 and 6 but still same error..
Can any one please help..
Finally the issue is resolved.. My ComSpec environment variable whose value is %SystemRoot%\system32\cmd.exe had a ";" at the end, which was causing this issue. I just removed ";" and yuppie.. it worked..
What actually happened here is that cmd command can not be found.
I got the same problem today on Windows 7, NodeJS 5.4, Cordova 5.4.1. cordova platform add android failed to work because of unknown issue. However, cordova -d platform add android actually showed some clues. cordova platform add android is a wrapper over the real command: cmd /s /c "..../create.bat" .... When you executed that command manually, you would know the underlying error: 'cmd' is not recognized as an internal or external command.
I have to change ComSpec environment variable from %SystemRoot%\system32\cmd.exe to %SystemRoot%\system32\cmd.exe;%SystemRoot%\system32 to make it work.
If it does not work, please add %SystemRoot%\system32 intp PATH as well
You've entered the wrong command.
Try this
cordova platform add android
fix is here (FOR WINDOWS ONLY)
I am facing the same problem of Build then i finally found out the solution.
SOLUTION
So You must have the Android Api 23 in order for this command to work.
Error of Daemon process will be solve after installing the Api 23 and extra build tools and run command
COMMAND : cordova build android --release
I am sure this fix would help you to solve the problem.
STEPS
1. First check the version of android through this COMMAND:
cordova platform help
2. Run the build command after installing the Api 23 and extra build tools.
3. If Even this not work then Try add the variable in the
Environment variables > System variables >
add _JAVA_OPTIONS and value = -Xmx512M
Then Run cordova build android --release
BUT FIRSTLY SET UP THE ENVIRONMENT VARIABLES
Environment Variable setup Image
android API 23
COPY FROM HERE
ENVIRONMENT VARIABLES:-
USER VARIABLES
PATH
C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo
ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
SYSTEM VARIABLES
ADD NAME AND VALUE
2.1 _JAVA_OPTIONS -Xmx512M
2.2 ANDROID_HOME C:\ANDROID_SDK
2.3 PATH ->
C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs;C:\Gradle\gradle-4.0\bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
I installed cordova e phonegap via npm install -g cordova and npm install -g phonegap respectively. Then i created a HelloWorld application via cordova create HelloWorld mynamespace.helloworld HelloWorld. It worked fine! Then i changed my working directory to HelloWorld and i tried to build the app for android via cordova platform add android -d but it didn't work. here is the output:
Installing cordova library for android...
Requesting {"uri":"https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot;h=3.3.0;sf=tgz"}...
Downloading cordova library for android...
Downloaded, unzipped and extracted 541065 byte response.
Download complete
Installing cordova library for android...
Checking if platform "android" passes minimum requirements...
Creating android project...
Running bin/create for platform "android" with command: ""C:\Users\marcos.pacheco\.cordova\lib\android\cordova\3.3.0\bin\create" "C:\Dev\HelloWorld\platforms\android" "mynamespace.helloworld" "HelloWorld"" (output to follow)
C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
at C:\Users\marcos.pacheco\AppData\Roaming\npm\node_modules\cordova\src\platform.js:244:30
at exithandler (child_process.js:633:7)
at ChildProcess.errorhandler (child_process.js:649:5)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:787:12)
I've googled and have found some issues with whitespaces but my project is in the C:\Dev\HelloWorld path and my android sdk is in the PATH so that when i type adb at the windows prompt i get the help information of the command as well Java and Ant. Furthermore, i have ANT_HOME, JAVA_HOME and ANDROID_HOME set. I also deleted the ** .cordova ** folder inside my %HOMEPATH% directory and entered the command again but the error is still there.
What might be wrong?
XCOPY needs to be defined and found on your path as it is used by the internal node.js scripts to move things around.
You probably already have xcopy.exe somewhere on your machine. You should be able to add %SystemRoot%\System32 to your PATH and it will work. Or you can open up a terminal and type where xcopy to see the actual path to your xcopy.exe.
I guess having XCOPY on the path is a requirement for setting up and installing Android, but it'd be nice if Cordova checked to make sure you have XCOPY somewhere...
UPDATE 1:
This was everything I did in the end:
sudo aptitude install -y python-software-properties python g++ make
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo aptitude update
sudo aptitude install nodejs
sudo aptitude install npm
sudo npm install -g cordova
sudo npm install -g phonegap
phonegap create my-app
cd my-app
export PATH=${PATH}:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/tools
sudo aptitude install ant
cordova platform add android
android create avd --name my_and --target 1
phonegap run android
Was any of that not neccessary?
ORIGINAL QUESTION:
On my Ubuntu 12.04 computer, I've just installed node.js with npm and cordova:
$ node -v
v0.10.23
$ npm -v
1.3.17
$ cordova -v
3.3.0-0.1.1
When I try to add android:
$ cordova platform add android
I get the following output:
Creating android project...
/usr/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
/home/oshirowanen/.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 /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at /usr/lib/node_modules/cordova/src/platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Anyone know why this is happening and how to resolve it?
I get the same issue with PhoneGap.
It's possible that the Android tools binaries are not in your path.
According to the PhoneGap docs (http://docs.phonegap.com/en/2.9.0/guide_getting-started_android_index.md.html), you need to include the Android SDK's tools and platform-tools in your PATH environment variable.
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
where Development is the path you installed your SDK.
Run the "android" command from your adt\sdk\tools folder and install the latest Tools and SDK. Also make sure your PATH has the right variables.
For this you will need ANT to be installed , a JAVA JDK and an 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 these to your PATH variable like %ANT_HOME%/bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin
Close and re-open your cmd and run your command again.
I'm running Ubuntu 12.04 and was having the same problem as you until a few minutes ago.
The two things I've noted that I had missed during installation:
The Android version should be 19 and you should be able to type 'android' at the console and see some output or see a window pop-up. Make sure that you add the path to the folder where android.jar is located to your PATH variable, and set ANDROID_HOME to that same path as well. Typically, you would do this in your .bashrc file or in /etc/environment If you edit either of these files, you'll need to either 'source ~/.bashrc' or reopen your terminal to force it to reload the file. Type 'android' to make sure its working.
I observed that the cordova setup script was attempting to write files into a subdirectory 'add-ons' of the Android SDK. That directory does not exist in the Android 19 distribution itself. Consequently, I created it manually and made it writeable by my user account.
ex: Android distribution path:
/opt/android/
The path that its trying to write to:
/opt/android/sdk/add-ons
Once I had done that I was able to get past the problem you've noted above.
It looks like the cordova andorid library file corrupted in your home directory.
Try to remove home//.cordova directory and do this again cordova platform add android in your cordova project.
Make sure you have sourced /platform-tools and /tools to PATH.
Android
The Android command-line tools are built upon shell scripts. You must have the Android SDK's tools and platform-tools folders in your PATH!
Create a project
Run the create command with the following parameters:
Path to your new Cordova Android project
Package name, following reverse-domain style convention
Main Activity name
$ /path/to/cordova-android/bin/create /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
It looks like this error could also be caused by the absence of a compatible Android SDK version (at the moment 4.2).
I use cordova.
2days I have same problem"java,ant,android,cordova,command test is ok,
but run cordova platform add android show me Error: An error occurred while listing Android targets".
Now I fixit use:
"chmod 777 ant and android sdk place"
,then it will work.
I use ubuntu 14.04 32bit,
if the problem still exist please make sure that you have the right permissions try
sudo chmo-R 777 /home/your-user-name/.cordova/
Also make sure that you are NOT using sudo to add Android as a platform
This is incorrect in the default Cordova installation
sudo cordova platform add android
Just do
cordova platform add android
I've searched a lot for this, and what worked for me was setting the shell variable $ANDROID_HOME to the path of the sdk/ folder in my adt-bundle directory from android. Use export to do this:
export ANDROID_HOME="/Users/YOUR_USER/Developer/adt-bundle/sdk/"
but be sure to change the directory to match yours.
Good Luck!
Not sure if someone else had a problem with this, but when removed and added my platform again, I realized in my config.xml I had <icon src='...'> and the path inside the src was wrong.
Here was the error output I received when I added the platform again:cp: no such file or directory: C:\Users\{pathtofile}.png.
After I fixed the path, it worked fine.
It can be that your cordova installation have been corrupted try to remove your .cordova folder "rm -R ~/.cordova"
And "run cordova platform add android" again