How to connect Android device as Jenkins slave to execute automatic tests - android

I am trying to execute automatic tests using robotframework + appium + Jenkins.
My biggest problem is to set up the necessary infrastructure.
I have a Windows VM (slave) with 4GB RAM but the emulator took more than 30 minutes to getting started.
I do not have a physical server to connect the device by USB.
How can I set this up in a efficiently way?
Is it possible to set up an Android device directly as slave (connected to master via wi-fi) and install robotframework in the device?
How many RAM/CPU I need If I need to get a better VM where I can handle the emulator efficiently?
I appreciate suggestion. Thanks.

It is very unlikely you manage to configure your Android phone as a Jenkins slave. It's just too many libraries that you would need to build on your own so they run natively on Android. You would need to have the Jenkins slave, Appium, Robot Framework and your app running in the same phone, which isn't as powerful as any regular computer.
However, if your device is rooted, you can try something like WiFi ADB to at least get the lowest level layer to your phone available over the air. There is also a manual setup with no software available at How can I connect to Android with ADB over TCP?.
If rooting is not your option, but you can connect the device through USB just once (which I assume you can't do because probably you're using a cloud host like Azure and that's why you can't physically access the machine), do it and run adb tcip 5555 (or your desired port). This will allow you to desconnect the device and use it over WiFi with the trusted computer connected through USB (until you kill the ADB server!).
After any of both procedures, configure your project as usual and set the udid capability to the IP of your phone in the network (try to configure a static IP address) and its port, for example 192.168.0.24:5555. Before running the tests, you have to run adb connect 192.168.0.24:5555 so adb is aware of the device and Appium can find it.
You still will have some trouble getting the VM and the phone in the same network, but for that issue there are plenty of options available like configuring a VPN.

Related

Android development is in VM but need to deploy & debug in local device

I am doing an Android app by connecting to a Virtual machine in Azure cloud by connecting to it via RDP(Remote Desktop Protocol). One week ago I was doing my development in local machine but my machine crashed so I started working in cloud. Back then, working with my local machine I had these privileges
1)Using of 'use Host GPU' option while creating an Android Virtual Device
2) Use of HAXM or intel virtualization technology/Hypr-v as I had access to my BIOS to set that up.
And I have a Google nexus 7 device and I used to work with it when ever emulators cannot do the job.(Like taking a picture for real)
Remote VM, I have no access to BIOS in Azure so I cannot make use of HAXM to speed up my emulator and of course I cannot use HOST GPU option while creating the AVD. It takes a long time to fire up the emulator and to deploy again and again. (My VM is a Azure D4 with 8 cores and 28 gigs of RAM)
I need to find out a way to forward my adb port to local machine so I can deploy apk into local device but yet developing from the cloud.
I went through following links but did not have anything working for 4 days now. I am stuck with my development totally until I get a new machine. Can someone please help on debugging locally
Usb data cable comunication in Android
adb forward remote port to local machine
https://bitbucket.org/chabernac/adbportforward/wiki/Home
Especially if any of you have configured the third link (chabernac's
adbportforward) please help me by stating how to do it.
Both vm and mobile device should be on the same net to work flawlessly
Just plug your device via usb on localmachine and in terminal type
adb tcpip 5555 (or the port you want to use)
unplug your phone, test if you connect to the device
adb connect <device ip>
then
adb devices
it should show the device you're connected to
Now type this to disconnect from the device
adb disconnect
go to %HOMEPATH%\.android and copy the rsa keys:
adbkey
2adbkey.pub
Go on remote machine and paste those two files to the same path.
Repeat step 2 and 3 to check if the device is connected
This works on devices 4.2+
This is the article which helped me a lot
http://www.cleansoft.lv/debugging-android-applications-remotely/

Accessing same android device from Different platforms

I have windows, Ubuntu & Android platforms in the same network.
I can access the android device after connecting through adb connect <IP> command.
But I could access the android device through the Platform in which I have connected first. In the second platform it is showing device offline.
Is there anyway to access the android device from both windows & Ubuntu?
It has nothing to do with your 2 systems being "different platforms". An attempt to connect to the same adb devices from 2 Windows systems (or 2 Ubuntu systems for that matter) would produce the same result. adb was not designed to be used this way - adbd daemon on the device can only be connected to 1 adb host at a time.
Instead connect your android device to your Ubuntu system and use whatever remote access solution you prefer (x server, vnc, ssh, etc) to control it from your Windows system.

Linux CLI into Android

I was wondering if it is possible to terminal into my Android (Razr) and navigate the file system and processes like you would on any other Linux distribution. As it is supposed to be built on top of the Linux Kernel.
I find it annoying that you simply can't shut down most apps, like Firefox for example, from the phone's default UI, I wish there would be a way to find the process ID and kill it like you would on a regular Linux/Unix machine.
If you enable debugging and have the Android SDK installed then you can use adb shell to get a shell on the android device using the USB cable to a PC. If you want something just on the device, ConnectBot which is a SSH client application that is available for free, can provide a localhost only shell which will let you work as for most linux systems. Note that the shell is fairly restricted. A lot of common commands are missing.
adb shell
with your phone connected to your PC, via network or USB according to your device, with USB debug enabled.
I use the connectbot app; it's primarily useful as an ssh client but also allows you to run a local terminal session

Control a serial device (like usb printer) from an Android app

I have two questions about Linux Android.
In the documentation it says:
"Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device."
And apparently there is a way to send a command to serial port (USB) from ADB (Android).
So, I need to send commands (like AT commands) from android device to usb device (printer)
1) The ADB will be present on a real device with android?, which version?
2) is there another alternative?
Thanks in advance
And apparently there is a way to send a command to serial port (USB) from ADB (Android).
Not that I am aware of.
The ADB will be present on a real device with android?
adb is a program that is part of the Android SDK. It runs on your development machine. It does not run on the emulator. It does not run on the device.
is there another alternative?
Use the USB APIs and the Open Accessory Development Kit, perhaps.

Connect Eclipse to Android emulator on a different machine

Can't seem to find the following information although I'm pretty sure this should be possible:
I'm running an Android emulator on a machine A. I'm developing on another machine B in which I'm using Eclipse.
Now when I switch to the DDMS perspective in Eclipse, I want the emulator from machine A to show up in the devices tab.
The reason is, that the emulator is quite slow and it looks like running development and emulator on different machines might be a solution.
Since the emulator runs on a specific port, I'm pretty sure I just need to figure out how to tell eclipse where to look for emulators.
Thanks for any tips
You can tell adb to connect to a device listening on an IP address and TCP port. That device should then show up in eclipse. So the debug machine is easy.
The emulator machine may be harder. The emulator is listening for TCP connection on a local port. IIRC it has been established that there's no command line switch to make it listen on an external interface, though double check that. So you might have to modify and recompile the emulator, or use some kind of port-forwarder on the hosting machine. ssh might handle that for you though I'm sure there are other tools without the encryption overhead if that's not needed.
In the meantime, I found a very nice solution to the problem. I installed android-x86 (http://www.android-x86.org) in a virtual machine.
On the host, you then use the following commands to restart adb and connect to the vm:
adb kill-server
adb connect <VM-IP>:5555
Replace VM-IP with the actual IP of your virtual machine. If you're on a private network, the easiest way is to configure vm network as bridged so the VM gets its own IP address from the dhcp server. Should also work with Host-Only networks though as described here.
If all went well, you should see the android VM in the Eclipse debugger just like normal emulators.
Eclipse doesn't attach to the emulator directly.
The adb background process controls communication with the emulator (as well as real devices).
Adb listens on TCP port 5037 for incoming commands.
I haven't tried your scenario but this should get you started.
I did it with the following steps.
Start the emulator on the remote machine
Start a port forwarding application on the remote machine (forwarded tcp:5557 to localhost:5555)
Start adb with connect remote_machine_IP:5557 on my development machine
Start eclipse
Eclipse will find adb and list the device.
Follow these steps to connect your VM to eclipse IDE:
First run ICS from your VM and open up android command prompt. (Navigate to applications and run Terminal Emulator)
Type "netcfg" in terminal to find out IP of your vm
Then go to cmd(windows command prompt) and move to "platform-tool" folder in your android installation path(in my case cd C:\android-sdk-windows\platform-tools)
Then type "adb connect your ip" command (adb connect 190.156.10.122)
Now you can debug your android application in vm without pain. Try this and this
After struggling with this, I found this video that explained how to get emulator running on my mac while running my dev environment in a VM.
http://youtu.be/CacpPleWsZM

Categories

Resources