I have worked on automation tool(Appium) in android using Ubuntu PC.I have written test case and run using TestNG in eclipse.Whenever I have run test case I have got the error i.e.
Failed to start an Appium session, err was: Error: zipAlignApk failed. Error: Command failed: /bin/sh: 1: -f: not found
info: Error: zipAlignApk failed. Error: Command failed: /bin/sh: 1: -f: not found
at /usr/lib/node_modules/appium/lib/devices/android/adb.js:461:19
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)
I am also converting build to zipAlign and using this command
zipalign -f -v 4 "/home/android/Desktop/app.apk" "/home/android/Desktop/app1.apk"
Please suggest me how to fix this issue
Seems like this is related to your zipAlignApk install location. You might just need to make a symlink in your /bin/sh directory. Don't think this is related to appium
It would seem that the command you are using is -f, not zipalign as you intended. The error message shows that your toolchain (specifically on line 461 of adb.js) ran a shell script/command. The shell (/bin/sh) started and tried to locate the executable it was told to run: -f. It could not find an executable file named -f in its $PATH, so it failed.
Since -f is supposed to be the first argument you pass to zipalign I would suspect that however it is that you put that command in your tools is incorrect and the command itself is missing when the shell is invoked.
Related
I set both ANDROID_HOME and PATH for tools.
my .bashrc ends with
export PATH="$PATH:/home/toskan/dev/android-sdk-linux/tools:/home/toskan/dev/android-sdk-linux/platforms"
export ANDROID_HOME=/home/toskan/dev/android-sdk-linux
if I echo $PATH i get
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/toskan/dev/android-sdk-linux/tools:/home/toskan/dev/android-sdk-linux/platforms
if I echo $ANDROID_HOME
I get
$ echo $ANDROID_HOME
/home/toskan/dev/android-sdk-linux
When I run
$ sudo ionic build android
I get
toskan#mycomp:~/IdeaProjects/myappmaster$ sudo ionic build android
Running command: /home/toskan/IdeaProjects/myappmaster/hooks/after_prepare/010_add_platform_class.js /home/toskan/IdeaProjects/myappmaster
add to body class: platform-android
Running command: /home/toskan/IdeaProjects/myappmaster/hooks/after_prepare/020_remove_sass_from_platforms.js /home/toskan/IdeaProjects/myappmaster
Running command: /home/toskan/IdeaProjects/myappmaster/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/toskan/IdeaProjects/myappmaster/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/toskan/IdeaProjects/myappmaster/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: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)
ANDROID_HOME is set and the command in the commandline
android
opens the android package manager
what am I missing?
the problem was indeed the following:
sudo doesn't read the PATH, it has it's own path that gets reset for security reasons.
You can change that path in the file
/etc/sudoers
there is the sudo own PATH
or something see this
sudo changes PATH - why?
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.
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'
I am trying to create a blank project using ionic framework. But I'm getting the following error when I run the ionic emulate android command.
Error executing "adb devices": /bin/sh: 1: adb: not found
Error: /home/username/todo/platforms/android/cordova/run: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135: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)
I also have added android sdk path to .bashrc file.
export ANDROID_HOME="$HOME/username/android/eclipse/adt-bundle/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/username/eclipse/adt-bundle/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
I have also install the eclipse adt bundle for 64 bits. any kind of help would be appreciated.
Error executing "adb devices": /bin/sh: 1: adb: not found
Do you have adb in your path? If not, put it. It comes with android sdk
I'm trying to successfully install and create an app with cordova but it doesn't works.
So I've Googled and read many threads here on Stack Overflow but it hasn't helped.
Here's my problem:
If I try to add the Android platform via CMD with
cordova platform add android
I get the folowing error:
Error: ERROR : executing command 'ant', make sure you have ant installed and added
to your path.
at C:\Users\user\.cordova\lib\android\cordova\3.4.0\bin\lib
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)
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\user\AppData\Roaming\npm
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)
I've downloaded Apache ant and unzipped it into C:\ant.
My env vars are the following:
Path:
C:\Program Files\nodejs\;C:\dev\adt-bundle-windows-x86_64-20131030\sdk\platform-
tools;C:\dev\adt-bundle-windows-x86_64-20131030\sdk\tools;C:\Program
Files\Java\jdk1.7.0_40;C:\ant
(I tried c:\ant\bin and c:\ant)
JAVA_HOME:
C:\Program Files\Java\jdk1.7.0_40
ANT_HOME:
C:\ant
And it still isn't working. How can I fix this?
Use this one
Install ant using brew
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install Apache Ant via Homebrew by executing
brew install ant
Run the PhoneGap build again and it should successfully compile and install your Android app.
add C:\ant\bin; in your system path.
Then open cmd prompt. type ant -version if show like this. you will fix it.
ant -version
Apache Ant(TM) version 1.9.2 compiled on July 8 2013
if it's didn't resolve your problem then check your ant install path. May be C:\Program Files\ant\bin .then add it to your system path.
enjoy your code.