Cordova - android error when building - android

This is my first experience in cordova. I created the helloworld project and installed the android platform correctly. When I tried to build the project by cordova build android, it shows this error message.
Running command: /home/menaka/hello/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/menaka/hello/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/menaka/hello/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:131: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)
But I have successfully set the ANDROID_HOME variable and PATH.
menaka#menaka-X550LC:~/hello$ echo $ANDROID_HOME
/Extra/Softwares/Android/Sdk/
So, what would be the reason for this?

Related

Cordova CLI can't find Android SDK using Windows 10

I have set my Environment Variables, yet I continue to get the following 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
at ChildProcess.whenDone (C:\Users\oneilj\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
I have uninstalled Android Studio and all the SDKs, and even un-installed nodeJS and cordova. After re-installing everything I still get the error.
I found this while waiting for an answer. The fix was from another user's question and answer:
Download tools_r25.2.3-windows.zip from Android Downloads.
Extracted zip on desktop
Replaced C:\Users\username\AppData\Local\Android\sdk\tools with extracted sub-folder tools/
In project folder:
$ cordova platforms remove android
$ cordova platforms add android

Keep getting: Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1

I'm new to this and I just wanted to do the things in this Tutorial:
Installing Cordova & Android SDK on Windows 7, 8 & 10 to Develop Mobile app
At 7:36 it's shown that I have to type:cordova platform add android
I did it but I'm getting this:
Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (G:\Cordovatest\hello\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:829:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Error: cmd: Command failed with exit code 1
Hope to get some help-
please do the following:
1) Add the environment variables, ANDROID_HOME and JAVA_HOME ( giving the path of the folder Android SDK and the one of JDK in the value).
2) In the System Variable PATH, add the path of the platform-tools the one of the Tools folder.
It will fix your error successfully.
Case Ionic Solution plugin fail whitelisterror
invoking the location of the java_home executable ie java.exe then recompiling
reason: the environment variables did not load at that time fail windows, because if they were well declare, Thanks

Cordova missing ANDROID_HOME variable to emulate

How can I get the emulator working? Cordova missed the ANDROID_HOME environment variable, but it is set as the terminal output below shows
In NetBeans works only debug by using the browser of the device, but not the emulation of the app as APK
yves#dell-xps:~/NetBeansProjects/moTion$ sudo cordova emulate
[sudo] password for yves:
Running command: /home/yves/NetBeansProjects/moTion/platforms/android/cordova/run --emulator
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: /home/yves/NetBeansProjects/moTion/platforms/android/cordova/run: 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.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
yves#dell-xps:~/NetBeansProjects/moTion$ echo $ANDROID_HOME
/home/yves/Android/Sdk

Cordova build issue in ubuntu

I was following the tutorials # http://www.gaggl.com/2014/04/apache-cordova-development-environment-install-on-ubuntu/
Cordova build is failing with message:
:~/projects/Hello$ sudo cordova build
Running command: /home/skn/projects/Hello/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/skn/projects/Hello/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/skn/projects/Hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I have included the android in the path variable also.
skn#bangre:~/projects/Hello$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin/java:/usr/bin/ant:.:/home/skn/android-sdk-linux/tools:/home/skn/android-sdk-linux/platform-tools
From screenshot below you can see the sdk is installed
Also I have the following check which is passing.
skn#bangre:~/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin$ ./android_sdk_version
21
skn#bangre:~/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin$ ./check_reqs
Looks like your environment fully supports cordova-android development!
Please help me point out the issue.
yes turns out the cordova node.js scripts assumes the android sdk directory name as 'android-sdk' , for ubuntu when we unzip we get 'android-linux-sdk'

cordova build error on ubuntu when trying to build from terminal

I am getting the following error when trying to build sencha app in terminal on ubuntu meachine..
edge#edge-HP:~/Desktop/Anupam2014/MobileAtSite_Aug23/cordova$ cordova build
Running command: /home/edge/Desktop/Anupam2014/MobileAtSite_Aug23/cordova/platforms/android/cordova/build
Buildfile: /home/edge/Desktop/Anupam2014/MobileAtSite_Aug23/cordova/platforms/android/build.xml
BUILD FAILED
/home/edge/Desktop/Anupam2014/MobileAtSite_Aug23/cordova/platforms/android/build.xml:90: Cannot find
/home/transnoesis/Downloads/adt-bundle-linux-x86_64-20130729/sdk/tools/ant/build.xml imported from
/home/edge/Desktop/Anupam2014/MobileAtSite_Aug23/cordova/platforms/android/build.xml
Total time: 0 seconds
Error code 1 for command: ant with args: debug,-
f,/home/edge/Desktop/Anupam2014/MobileAtSite_Aug23/cordova/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /home/edge/Desktop/Anupam2014/MobileAtSite_Aug23/cordova/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:126: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)
This looks path settings issue and is unable to find path to sdk & ant tools.
Currently I am on Windows and see how I've set paths on Windows, so you check and set yours accordingly on Ubuntu, hope will help you.
ANT_Home: C:\Program Files\apache-ant-1.9.4
Java_Home: C:\Program Files\Java\jdk1.7.0_60
ANDROID_HOME: C:\Android\AndroidSDK\sdk
path:.;C:\Program Files\nodejs\;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;

Categories

Resources