Error while building android platform at cmd - android

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

Related

How to download Android sdk and set android_home path on Windows?

When I download from http://developer.android.com/sdk/index.html, I am getting the .exe file, and I'm having trouble setting the path. How to set the path ANDROID_HOME on Windows? When I build the ionic app I'm getting the below error
[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.]
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
For windows:
Right click on My computer -> properties -> Advanced system setting -> Environment Variables
Now Edit Path on system variables and append at the end of the line:
;C:\yourSdkDirectoryLocation\tools;C:\yourSdkDirectoryLocation/platform-tools
Error: ANDROID_HOME is not set and "android" command not in your PATH on OS X
I'm not exactly sure about your error, but if you're trying to change a value in PATH variable (Windows) here and I would appreciate some more information about your issues.

Ionic Error: may not have the required environment or OS to build this project

I'm running Ionic on Ubuntu. I have the Android sdk installed and already installed the tools to work with it.
When I try to run ionic build android I got the error:
Running command: /home/fernando/Dropbox/Code/Kelps/KelpsApp/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/fernando/Dropbox/Code/Kelps/KelpsApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/fernando/Dropbox/Code/Kelps/KelpsApp/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
I'm tried to look this on google, and have too much information and no solution about this.
Someone already got this error?
Thanks!
Yes, I have met this error before.
But as your log we can see what the problem is:
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
You have installed the sdk but haven't set the PATH to it.
For Windows user try the following step:
Open up the System Environment from:
Control Panel -> System -> Advanced system settings -> Select Advance tab
Click on Environment Variables...
In the User variables for ... section click on the New button.
Then type ANDROID_HOME in Variable name, and the path to the sdk folder in Variable Value
OK, OK, OK
Restart the command line and try again with ionic command.
For Ubuntu, I don't use this OS so please check this solution
Find my answer at this post :
https://www.thepolyglotdeveloper.com/2014/09/install-android-cordova-ionic-framework-ubuntu/

PhoneGap Cordova Build Error Exit Code 2

I'minstalled PhoneGap and made one simple app that works on my tablet when using PhoneGap server and PhoneGap App for android. Now I want to makean APK but I'm gatting error when runsudo phonegap build android in APP folder:
miljan#Miljan-PC:~/Desktop/HelloWorld$ sudo phonegap build android
[sudo] password for miljan: [phonegap] executing 'cordova build
android'... cp: no such file or directory:
/home/miljan/Desktop/HelloWorld/icon.png
Running command:
/home/miljan/Desktop/HelloWorld/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your
PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error:
/home/miljan/Desktop/HelloWorld/platforms/android/cordova/build:
Command failed with exit code 2 You may not have the required
environment or OS to build this project
Error:
/home/miljan/Desktop/HelloWorld/platforms/android/cordova/build:
Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134: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)
In ~/.profile I have add this:
export ANDROID_HOME=/home/miljan/Android-SDK-Linux
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools
How I can slove this problem?
Anyone who can help?
I had the same problem when I was using ionic to build android. I used this solution to solve my problem
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
use the third solution and don't use the exact paths which are given here. In the android_home give the path of your sdk. in the android_tools give the path of tools in the sdk and in the third give the platform path given in the sdk.
and if you have problem after this too userchmod 777 /sdk/tools and chmod 777 /sdk/tools/android.
May this solution helps

Cordova add platform android error

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;

Installing PhoneGap, error executing command 'ant'

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!

Categories

Resources