Cordova build issue in ubuntu - android

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'

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

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 - android error when building

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?

cordova build android throws error on Ubuntu 12.04

The issue looks very familiar with this
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
But I am not able to fix it. When I run
% sudo cordova build android
I am getting the following error
Running command: /home/thabung/mobile/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/thabung/mobile/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/thabung/mobile/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)
Few things I am observing
% echo $ANDROID_HOME
returns me
~/mobile/android-sdk-linux
which is perfect location
& android command also works fine.
Please help..
I am using cordova 4.3.0
This ...
sudo cordova build android
runs in the environment of root whereas this ...
echo $ANDROID_HOME
was not executed as root. Check what echo $ANDROID_HOME returns as root - or (strongly recommended) - run Cordova as another user than root.
p.s.: I'm running Cordova 4.0.0 on Ubuntu 14.04 without sudo.

Categories

Resources