Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / docs / working_remotely_with_android.md
blob1452d8c818f32045a8ce177b5f7e93052327d4f3
1 # Working remotely with Android
3 [TOC]
6 ## Introduction
8 When you call /build/android/run_tests.py or
9 /build/android/run_instrumentation_tests.py it assumes an android device
10 is attached to the local host.
12 TODO: these scripts do not exist.
14 If you want to work remotely from your laptop with an android device attached to
15 it, while keeping an ssh connection to a remote desktop machine where you have
16 your build environment setup, you will have to use one of the two alternatives
17 listed below.
19 ## Option 1: SSHFS - Mounting the out/Debug directory
21 ### On your remote host machine
23 You can open a regular ssh to your host.
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
31 See also
32 [Android Build Instructions](https://www.chromium.org/developers/how-tos/android-build-instructions).
34 ### On your laptop
36 You have to have an android device attached to it.
38 ```shell
39 # Install sshfs
41 laptop$ sudo apt-get install sshfs
43 # Mount the chrome source from your remote host machine into your local laptop.
45 laptop$ mkdir ~/chrome_sshfs
46 laptop$ sshfs your.host.machine:/usr/local/code/chrome/src ./chrome_sshfs
48 # Setup enviroment.
50 laptop$ cd chrome_sshfs
51 laptop$ . build/android/envsetup.sh
52 laptop$ adb devices
53 laptop$ adb root
55 # Install APK (which was previously built in the host machine).
57 laptop$ python build/android/adb_install_apk.py --apk ContentShell.apk --apk_package org.chromium.content_shell
59 # Run tests.
61 laptop$ python build/android/run_instrumentation_tests.py -I --test-apk ContentShellTest -vvv
62 ```
64 *** note
65 This is assuming you have the exact same linux version on your host machine and
66 in your laptop.
67 ***
69 But 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.
70 In this case you will have to recompile these binaries in your laptop:
72 ```shell
73 # May need to install dependencies on your laptop.
75 laptop$ sudo ./build/install-build-deps-android.sh
77 # Rebuild the needed binaries on your laptop.
79 laptop$ build/gyp_chromium -DOS=android
80 laptop$ ninja -C out/Debug md5sum host_forwarder
81 ```
83 ## Option 2: SSH Tunneling
85 ### Option 2a: Use a script
87 Copy /tools/android/adb_remote_setup.sh to your laptop, then run it.
88 adb_remote_setup.sh updates itself, so you only need to copy it once.
90 ```shell
91 laptop$ curl "http://src.chromium.org/svn/trunk/src/tools/android/adb_remote_setup.sh" > adb_remote_setup.sh
92 laptop$ chmod +x adb_remote_setup.sh
93 laptop$ ./adb_remote_setup.sh <desktop_hostname> <path_to_adb_on_desktop>
94 ```
96 ### Option 2b: Manual tunneling
98 You have to make sure that ports 5037, 10000, ad 10201 are not being used on
99 either your laptop or your desktop. Try the command: `netstat -nap | grep 10000`
100 to see
102 Kill the pids that are using those ports.
104 #### On your host machine
106 ```shell
107 desktop$ killall adb
108 desktop$ killall host_forwarder
111 #### On your laptop
113 ```shell
114 laptop$ ssh -C -R 5037:localhost:5037 -R 10000:localhost:10000 -R 10201:localhost:10201 <desktop_host_name>
117 #### On your host machine
119 ```shell
120 desktop$ python build/android/run_instrumentation_tests.py -I --test-apk ContentShellTest -vvv