Installing Phonegap on Windows 7 : The command 'android' failed - android

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.

Related

Android SDK installed but not found

I'm installing an environment for an Ionic project on Windows 10. I downloaded Android studio and installed SDK in
C:\Users\user\AppData\Local\Android\sdk
My system variable ANDROID_HOME=C:\Users\user\AppData\Local\Android\sdk
Executed OK:
ionic platform add android
But :
$ ionic run android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\KGE\SVN\trunk\sagaMobile\hooks\after_prepare\010_add_platform_class.js C:/Users/KGE/SVN/trunk/sagaMobile
add to body class: platform-android
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.
I tried to find a solution for 2 days but nothing works. If you have any ideas ...
EDIT:
I use Git bash for input. I have the same with CMD, even as admin.
EDIT 2:
Solved by removing and reinstall of the whole project

phonegap run android - create Command failed with exit code 8 - linux

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

An error occured during creation of android sub-project

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...

An error occured During creation of phonegap android sub project

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

Cordova and setting Android using command line

I am trying to migrate my existing project from cordova 2.1 to the latest, 3.1 which can be installev vía command line,
I already have the Android SDK installed,
So:
sudo npm install -g cordova // All good
cordova create hello com.example.hello HelloWorld // All good
cordova platform add android // Then it fires:
Checking Android requirements...
[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 path. Output: ]
So I installed Macports and tried:
sudo port install android
Which logs:
Warning: All compilers are either blacklisted or unavailable; defaulting to first fallback option
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Cleaning android
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
Any idea what am I missing here?
It's work cordova Android for MAC 1000000000%. I fought solution and now i'm working try this #Toni Michel Caubet. I will happy to share my Answer.
STEPS:
Open Your Terminal and followed by,
touch ~/.bash_profile
open ~/.bash_profile
PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH" (This is Android SDK Location to stored in My system )
4.Save the file and quit the text editor.
5.Execute your .bash_profile to update your PATH:
source ~/.bash_profile
if you want to see your environment path:
7.In your terminal type: set
After you can see like
8.As far as your made it very correct. After your enter command like cordova platform add android. you get following error. because Java SDK doesn't too set environment PATH.
9.open ~/.bash_profile. Add JAVA_HOME value
10.You can see your environment like STEP 7 set. You should be able see:
11.Successfully created environment now you can create Android project with Cordova or PhoneGap
When you installed the Android SDK, it will come with a bunch of folders, like build-tools, platform-tools, tools, and some others. You need to add platform-tools and tools to your main $PATH environment variable.
See the docs here about how to add things to your PATH for whichever system you are on (Windows or Mac): http://cordova.apache.org/docs/en/3.1.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide
Here is how you would edit the $PATH on Windows:
Click on the Start menu in the lower-left corner of the desktop,
right-click on Computer, then click Properties.
Click Advanced System Settings in the column on the left.
In the resulting dialog box, press Environment Variables.
Select the PATH variable and press Edit.
Append the following to the PATH based on where you installed the
SDK, for example: ;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools
Save and close both dialogs.
To install the cordova command-line tool, follow these steps:
First of all go through the Cordova Document
For Cordova command-line tools to work, you need to include the SDK's tools and platform-tools directories in your PATH environment. On Mac, you can use a text editor to create or modify the ~/.bash_profile file, adding a line such as the following, depending on where the SDK installs:
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
Next Steps:
Download and install Node.js from Here. Following installation, you should be able to invoke node or npm on your command line.
Install the cordova utility. In Unix(Mac), prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories:
For Mac $ sudo npm install -g cordova
once successful installation of cordova is done ,now you can create your application
across all the platforms.
Create the Cordova Application
Go to the directory where you maintain your source code, and run a command such as the following:
$cordova create hello com.example.hello CordovaDemo
hello is the directory where you want to create your application
com.example.hello is the package name
CordovaDemo is the name of the Application
Once Successful creation of your project, some file will be created inside the directory i.e hello
Add Platforms
All subsequent commands need to be run within the project's directory, or any subdirectories within its scope:
$ cd hello
Now you need to specify a set of target platforms, Supported OS for Mac
$ cordova platform add android
plz tell me if you are still having problem.
[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 path. Output: ]
You just need to install the Latest version of Android i.e 4.3
Go to SDK Manager and install the latest SDK Platform.
And try run the command again.
Hope this will help you.
Here it solved my issue:
into the terminal.
touch ~/.bash_profile (create a bash profile)
open ~/.bash_profile (opening a bash profile)
in your opened file, please type the following, Make sure that you have given the correct path, in case you find it difficult to find your directory in which your Android SDK is installed , search into your terminal with ls -l.
PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH"
[Let me clarify first that, this is windows specific suggestion, answer]
For particular cordova version there corresponds particular android API
So,
First check out version of cordova with following command:
$ npm cordova -v
In my case cordova version was 1.4.28 , which corresponds to Android API 19
So the bottom line is don't waste time in downloading all "SDK Platforms"
instead just download corresponding Android API for concerned cordova version...
Hope this help....!!!

Categories

Resources