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...
Related
I did some googleing but find nothing approriate.
Any help appreciated. Try it with an naked vm to be sure
having no nodejs install or dependency issue.
Christian
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo npm install -g phonegap
sudo npm install -g cordova
sudo apt-get install ant
chris#mint16 ~/project/dev $ phonegap create my-app
[phonegap] create called with the options /home/chris/project/dev/my-app com.phonegap.helloworld HelloWorld
[phonegap] Customizing default config.xml file
[phonegap] created project at /home/chris/project/dev/my-app
chris#mint16 ~/project/dev $ cd my-app/
chris#mint16 ~/project/dev/my-app $ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
{ [Error: /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
I've just faced the same issue, the problem was that path to sdk tools was not properly setup:
So try the following:
export PATH=$PATH:/usr/local/adt-bundle/sdk/tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/platform-tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/build-tools
I also hit the same issue, but just adding the various android sdk tools directories to the path as DKMudrechenko suggested above did not help. It turned out that I had not installed ant properly. I had downloaded it from apache.org and just added the ant 'bin' folder to my path, but apparently that wasn't good enough. However, after removing that entry from my path statement and adding ant via brew, I was then able to build the android cordova project successfully using the 'cordova build android' command.
i have been facing this issue on and off only to realise that the build fails for other errors in the code/configuration.
the process you have taken does skip one part where the android platform is added
corodova platforms add android
in the steps given above, you have created a project, traversed into the project directory and then ran the build, to which the phone gap checked the installed sdks by checking ANDROID_HOME and tried to set up the project for android.
you might want to run it in a correct order:
create project
move to the project directory
add platform
build / run.
i hope this helps
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!
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
I am trying to build a phonegap android,At that time i got a message that
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during craetion of android sub-projesct. creating cordova project for the android platform
Please help me.
Thanks in advance.
Seems ant binary missing in your path!
In you install ant with npm like:
sudo npm install -g ant
Then just make symlink to bin folder what found in your $PATH like
sudo ln -s /usr/local/lib/node_modules/ant/ant/bin/ant /usr/local/bin/ant
There may be one of following two reasons-
1) .cordova directory already exists on your machine in your user folder. Delete it and try your command.
2)You have xcopy.exe somewhere on your machine. You should be able to add %SystemRoot%\System32 to your PATH.
or You can find it by running 'where xcopy' in your terminal window. XCOPY on the path is a requirement for setting up and installing Android
You need to define XCOPY on your path as it is used by the internal node.js scripts to move things around.
One of these should solve your problem.
I had same problem with cordova 3.3.1 and phonegap 3.3.0. Finally, I opened Android SDK manager and found out Platform tools were outdated, though I had the latest version from here. After update, this error was gone
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.
Similiar to PhoneGap/Cordova Android Development
I followed the documentation and some tutorials on Phonegap to install it on Windows 7, but I'm stuck.
So far, I've installed Java 1.7.0_06, Ant-Apache 1.9.2, Eclipse, Android SDK with Android 4.3 (API 18), all Tools and all Extras in the SDK Manager), NodeJS 0.10.18 and Git.
I wrote all paths in the PATH variables in Windows it's look like this (decomposed) :
F:\nodejs;
F:\android-sdk\sdk\platform-tools;
F:\android-sdk\sdk\tools;
%JAVA_HOME%\bin;
%ANT_HOME%\bin;
C:\Program Files (x86)\Git\bin
Where %JAVA_HOME% and %ANT_HOME% have the right path, they give me the their version when I type java -version or ant -version in the CLI
So I went in the CLI, I installed Phonegap with the following command :
npm install -g phonegap
It give me the 3.0.0-0.14.3 version when I type phonegap -v.
Now, I went to my folder F:\apps and I created a new project with the following command :
phonegap create hello com.example.hello HelloWorld
Everything goes well, the files are created.
I went in the 'hello' folder, and I typed this command :
phonegap local build android
And there come the problem, I get this error :
[phonegap] adding the Android platform...
[error] The command `android` failed. Make sure you have the latest AndroidSDK installed, and the `android` command (inside the tools/ folder) added to your path. Output:
I tried this command too :
phonegap build android
But it get stuck at this, nothing happen next :
[phonegap] detecting Android SDK environment...
[phonegap] using the remote environment
[phonegap] compressing the app...
After lot's of research, I don't know what I can do anymore to find the problem, and I'm quiet new with all this CLI... So yeah, do you have any idea why the command 'android' failed ?
Thanks
Open environment variables, on the first part 'user variables' add new variable with this name android and the variable F:\android-sdk\sdk\tools;
Then edit the user variables PATH and add this at end of the line %android%;
close your CMD and try again.