blob: 1452d8c818f32045a8ce177b5f7e93052327d4f3 [file] [log] [blame] [view]
nodir02eda382015-08-25 14:55:521# Working remotely with Android
andybons3322f762015-08-24 21:37:092
nodir02eda382015-08-25 14:55:523[TOC]
andybons3322f762015-08-24 21:37:094
5
nodir02eda382015-08-25 14:55:526## Introduction
7
8When you call /build/android/run_tests.py or
9/build/android/run_instrumentation_tests.py it assumes an android device
10is attached to the local host.
11
12TODO: these scripts do not exist.
13
14If you want to work remotely from your laptop with an android device attached to
15it, while keeping an ssh connection to a remote desktop machine where you have
16your build environment setup, you will have to use one of the two alternatives
17listed below.
18
19## Option 1: SSHFS - Mounting the out/Debug directory
andybons3322f762015-08-24 21:37:0920
21### On your remote host machine
andybons3322f762015-08-24 21:37:0922
nodir02eda382015-08-25 14:55:5223You can open a regular ssh to your host.
24
25 # build it
26 desktop$ cd $SRC;
27 desktop$ . build/android/envsetup.sh
28 desktop$ build/gyp_chromium -DOS=android
29 desktop$ ninja -C out/Debug
30
31See also
32[Android Build Instructions](https://www.chromium.org/developers/how-tos/android-build-instructions).
andybons3322f762015-08-24 21:37:0933
34### On your laptop
nodir02eda382015-08-25 14:55:5235
36You have to have an android device attached to it.
37
38```shell
andybons3322f762015-08-24 21:37:0939# Install sshfs
nodir02eda382015-08-25 14:55:5240
andybons3322f762015-08-24 21:37:0941laptop$ sudo apt-get install sshfs
42
43# Mount the chrome source from your remote host machine into your local laptop.
nodir02eda382015-08-25 14:55:5244
andybons3322f762015-08-24 21:37:0945laptop$ mkdir ~/chrome_sshfs
46laptop$ sshfs your.host.machine:/usr/local/code/chrome/src ./chrome_sshfs
47
48# Setup enviroment.
nodir02eda382015-08-25 14:55:5249
andybons3322f762015-08-24 21:37:0950laptop$ cd chrome_sshfs
51laptop$ . build/android/envsetup.sh
52laptop$ adb devices
53laptop$ adb root
54
55# Install APK (which was previously built in the host machine).
nodir02eda382015-08-25 14:55:5256
andybons3322f762015-08-24 21:37:0957laptop$ python build/android/adb_install_apk.py --apk ContentShell.apk --apk_package org.chromium.content_shell
58
59# Run tests.
nodir02eda382015-08-25 14:55:5260
andybons3322f762015-08-24 21:37:0961laptop$ python build/android/run_instrumentation_tests.py -I --test-apk ContentShellTest -vvv
62```
63
nodir02eda382015-08-25 14:55:5264*** note
65This is assuming you have the exact same linux version on your host machine and
66in your laptop.
67***
andybons3322f762015-08-24 21:37:0968
69But if you have different versions, lets say, ubuntu lucid on your laptop, and the newer ubuntu precise on your host machine, some binaries compiled on the host will not work on your laptop.
70In this case you will have to recompile these binaries in your laptop:
nodir02eda382015-08-25 14:55:5271
72```shell
andybons3322f762015-08-24 21:37:0973# May need to install dependencies on your laptop.
nodir02eda382015-08-25 14:55:5274
andybons3322f762015-08-24 21:37:0975laptop$ sudo ./build/install-build-deps-android.sh
76
77# Rebuild the needed binaries on your laptop.
nodir02eda382015-08-25 14:55:5278
andybons3322f762015-08-24 21:37:0979laptop$ build/gyp_chromium -DOS=android
80laptop$ ninja -C out/Debug md5sum host_forwarder
81```
82
nodir02eda382015-08-25 14:55:5283## Option 2: SSH Tunneling
andybons3322f762015-08-24 21:37:0984
nodir02eda382015-08-25 14:55:5285### Option 2a: Use a script
andybons3322f762015-08-24 21:37:0986
nodir02eda382015-08-25 14:55:5287Copy /tools/android/adb_remote_setup.sh to your laptop, then run it.
88adb_remote_setup.sh updates itself, so you only need to copy it once.
andybons3322f762015-08-24 21:37:0989
nodir02eda382015-08-25 14:55:5290```shell
andybons3322f762015-08-24 21:37:0991laptop$ curl "http://src.chromium.org/svn/trunk/src/tools/android/adb_remote_setup.sh" > adb_remote_setup.sh
92laptop$ chmod +x adb_remote_setup.sh
93laptop$ ./adb_remote_setup.sh <desktop_hostname> <path_to_adb_on_desktop>
94```
95
nodir02eda382015-08-25 14:55:5296### Option 2b: Manual tunneling
andybons3322f762015-08-24 21:37:0997
nodir02eda382015-08-25 14:55:5298You have to make sure that ports 5037, 10000, ad 10201 are not being used on
99either your laptop or your desktop. Try the command: `netstat -nap | grep 10000`
100to see
andybons3322f762015-08-24 21:37:09101
102Kill the pids that are using those ports.
103
nodir02eda382015-08-25 14:55:52104#### On your host machine
105
106```shell
andybons3322f762015-08-24 21:37:09107desktop$ killall adb
108desktop$ killall host_forwarder
109```
110
nodir02eda382015-08-25 14:55:52111#### On your laptop
112
113```shell
andybons3322f762015-08-24 21:37:09114laptop$ ssh -C -R 5037:localhost:5037 -R 10000:localhost:10000 -R 10201:localhost:10201 <desktop_host_name>
115```
116
nodir02eda382015-08-25 14:55:52117#### On your host machine
118
119```shell
andybons3322f762015-08-24 21:37:09120desktop$ python build/android/run_instrumentation_tests.py -I --test-apk ContentShellTest -vvv
nodir02eda382015-08-25 14:55:52121```