Saturday 16 August 2014

Let's try Mobile Automation Setup [ Appium ]


Can something be more painful than setting up Appium in your specific OS [ Windows, Ubuntu, MAC ]? Agreed! then this blog it for you. Yes, I had been setting it up, couple of times on different OS but surprisingly each time, a new issue appears and sometimes set of issues, sigh!

Hold on! now you don't need to, because this will help you out
So start with basic necessities for all OS [http://appium.io/]

1. Install JAVA (jdk 6 or more)

2. Set java in the class path, its weird but strictly follow this:
For Windows 7: my computer ->right click--> properties--> advanced system settings-->environment variable--> create a new variable under system variable [not user variable], name it 'JAVA_HOME' and give path till java's directory
example: C:\Program Files\Java\jdk1.6.0_27
now open 'path' variable and add @ end of it ';%JAVA_HOME%\bin'
Test it : go to cmd and type 'java' or 'jvm', it should echo some message but not 'command not found'

3. Download android sdk for Android [ will post for IOS soon]
Adt: http://developer.android.com/sdk/index.html 4. Set the adb path in class path,
For Windows : like java, create a new variable under system variable, name it "ANDROID_HOME" and give path till adb
example: D:\Software\Android\android-sdk\
now open 'path' variable and add @ end of it ';%ANDROID_HOME%\platform-tools'
Test it : go to cmd and type 'adb', it should echo some message but not 'command not found'

5. Download Appium
For windows: AppiumForWindows-1.2.0.1.zip from https://bitbucket.org/appium/appium.app/downloads/

For linux: strictly follow this to save your time by not getting into unwanted issues
install via brew, if you don't have one, get homebrew
> brew install node # get node.js
> npm install -g appium # get appium
> npm install wd # get appium client
> appium & # start appium
> node your-appium-test.js

For MAC: download dmg file from https://bitbucket.org/appium/appium.app/downloads/

6. If using eclipse open it and add adt plugin
Top menu--> Help--> install new software --> add with name 'ADT' and site 'http://dl-ssl.google.com/android/eclipse/'
and set the sdk path in eclipse in preferences-->Android [ which we had downloaded ]




7. Create a emulator or connect a device with debugging on [ enable developer options in phone by tapping 7 times on 'model no']
7.1 For emulator: open SDK manager [check the android download icon in this image and install any android version as per need which is more than API level 16, better to communicate with dev team]

7.2 create a respective emulator on click of device icon shown in the image

8. Now your environment is ready
Let's do a smoke test of the system
Command prompt
java -version
appium -v
adb -v
for linux & MAC systems its easy - Appium comes with Appium doctor if you run it, it does the job

9. Windows & MAC :
Open appium, give package name (ask developers)
give IP address: 127.0.0.1 , port : 4723
if want to open inspector without running the test then set App path too

Linux: doesn't have ui version of Appium so run via 'Appium &' with respective run config to set path etc.

10. Now 1 by one
start emulator /plugin device with debug on
start appium server
start your test script, it shall listen & start the test in your emulator/device

Common Issues :

1. Linux:
1.1 brew not command
follow-https://github.com/Homebrew/linuxbrew or https://www.digitalocean.com/community/articles/how-to-install-and-use-linuxbrew-on-a-linux-vps 1.2 adb not recognised error solution: classpath setting is missing, set Android_home to be set in ~./bashrc

2. MAC
adb not recognized
solution: set Android_home in ~./bash_profile

3.Eclipse ERROR: transport error 202: bind failed: Address already in use ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized
Solution: Kill running java process from task manager or from command line

4.While installing apk
if error: Failure [INSTALL_FAILED_ALREADY_EXISTS]
Solution: adb install -r D:\Android\pathTillApk\MyApp.apk

5. [INSTALL_FAILED_UID_CHANGED]:When there is no app installed and while installing it throws error
"A new session could not be created. (Original error: Remote install failed: pkg: [INSTALL_FAILED_UID_CHANGED])", solution: from command line go to adbpath and hit this commands [it removes the existing data and makes enable to reinstall app without any issue]
- adb shell
- rm -rf /data/data/you_apk_pacakge_name 


6. [INSTALL_FAILED_CPU_ABI_INCOMPATIBLE]: 
Solution : check you apk's architecture, if it supports 86 then having an ARM architecture build won't work. So get help from dev and get a build which supports all architectures or at least its the same what your simulator/device requires.


Going to add more issues and solutions in some time, keep reading :-)

Important commands to deal with emulator


  • Create avd -->android create avd -n nameOfEmulatorWannaGive -t 1
  • Start emulator-->emulator -avd nameOfEmulatorWannaGive
  • Check if there is any emulator or device running-> adb devices
  • To deploy/install app : adb install D:\Android\app\nameOfYourApk.apk
  • To Start adb: ./adb start-server [in windows & MAC 'adb is fine but on linux machines './adb' works for executable]
  • To Stop adb: ./adb kill-server


  • Note: This guide can answer many of your problems: http://appium.io/slate/en/master/?ruby#setup

    No comments:

    Post a Comment

    Memories from Conference of the year

    Another happy day:-) Got the opportunity to meet & chat with the amazing people around the globe. The brilliant minds behind the inven...