Wikimedia Apps/Team/Android/App hacking/Chromebook

From mediawiki.org

Setup[edit]

Developing and testing an Android app on a Chromebook requires configuring the device to boot into developer mode via a process described here:

https://www.chromium.org/a/chromium.org/dev/chromium-os/developer-information-for-chrome-os-devices/generic

Booting[edit]

On boot, you will be presented with a boot screen informing you that OS verification is off, and inviting you to press space to reenable. Ignore this, and press Ctrl+D to launch the OS. You're in developer mode! There won't be any obvious indication of this, but you are.

If you press space as invited on boot, the machine will revert to regular (non-developer) mode. You don't want this.

Play store access[edit]

For an educational or enterprise Google account (such as a WMF staff account), Google Play store access must be enabled by WMF's Google accounts administrator in order to access the Android settings and enable loading unverified apps (like Wikipedia Dev). You can find the setting to enable Google Play in the Chrome settings (which essentially act as the device settings), but it might be greyed out, with an icon meaning that it's administrator-managed setting. If you don't have access, Office IT can enable it for you. You might consider sending along a link to the relevant support article, which is here:

https://support.google.com/chrome/a/answer/7131624

Connecting[edit]

Once Android is enabled, you can follow the steps here to connect over ADB and launch the app:

https://developer.android.com/topic/arc/index.html

In a nutshell, you can access the familiar Android settings screen from the Google Play section of the Chrome settings. Go to the Android settings, choose 'Security' and enable loading unverified apps, then enable Android developer mode and ADB debugging by the usual process. Connect to the Chromebook over ADB (on port 22, by default), accept the incoming ADB connection on the Chromebook, and you will be all set!

Update: As of mid-to-late 2017 these instructions no longer seem to work. All of my attempts to connect from another machine time out. Here's a workaround:

You can connect internally to the Android container from a bash shell on the Chromebook itself. Launch crosh with Ctrl-Alt-T and then invoke a bash shell by entering shell at the crosh prompt.

crosh> shell
chronos@localhost / $

ifconfig will report the existence of a veth_android interface with a IPv6 address. This is what we want to connect to. But ADB won't connect to an IPv6 address! There's a workaround for this as well. There's a configuration file, /etc/containers/android/sslh.conf, that contains an IPv4 address for the Android container (currently 100.115.92.2).

chronos@localhost / $ cat /etc/containers/android/sslh.conf
[...]
protocols:
(
 [...]
 { name: "adb"; service: "adb"; host: "100.115.92.2"; port: "5555"; probe: [ "^CNXN" ]; }
)

We can connect to this internally via ADB:

chronos@localhost / $ adb connect 100.115.92.2
connected to 100.115.92.2:5555

This should now be reflected if you check adb devices. For debugging, you can view the logcat with adb logcat.

APKs can be downloaded from Gmail/Google Drive/etc for installation and testing.