Before you can begin developing for Android Things, you need to make sure that you have a device that is running the OS. Until recently, the process for doing this varied between devices, and had a lot of manual steps. Luckily, Google introduced a new command line tool specifically for flashing Android Things with Android Things Developer Preview 6. Although this tool has been eclipsed a bit in popularity around the developer community by other new features that came out with the preview, the flashing tool is probably one of my favorite additions. It simplifies the process to a few options and handles a lot of the grunt work for you, including connecting a device to a wireless network.
Despite the tool being relatively self explanatory, finding it can be a little tricky. You will need to go to the Android Things Developer Console and either select an already existing product, or create a new one.
Once you’ve selected or created/setup a product, select the hamburger menu icon in the top left of the console screen. You should see a list of options appear, one of which is Tools.
At the time of this writing, there is only one tool available: Setup Utility.
Once you click on the green DOWNLOAD button, a .zip file will download containing the setup utility for either Windows, Mac OSX or Linux.
There’s also a handy README.md file that I’m sure most people ignore, but it has some useful information, such as which boards are currently supported by the utility,
and that you will need to run the script as an administrator/superuser if you are flashing a Raspberry Pi SD card. :)
From this point you can simply run the script and follow along with the prompts, though I’ll include that process here for completeness. This will be done on OSX to a Raspberry Pi SD card, though the process will mostly match on a Windows or Linux machine.
First, start the script. This will need to be done as an administrator/superuser for the Raspberry Pi.
This will cause a prompt to come up asking if you want to install Android Things on a device and configure WiFi, or just configure WiFi.
For this demo, select 1 to install Android Things on your device. You will then be prompted for the type of device that you are flashing. In this case it will be the Raspberry Pi 3.
This will begin the process of downloading additional configuration files before asking if you want to do a fresh install of the default image, or include a bundled custom image. Bundles for the custom image can be retrieved from the Android Things Developer Console once you have uploaded an Android Things program. For this walk through, select 1 to install the default image.
Selecting the default image option will begin the process of downloading the latest Android Things system image and a tool for writing to the SD card. When it has completed, you will be prompted to insert your SD card (in its adapter) into your computer.
After pressing the Enter key, you will be asked to select the drive for the SD card and confirm that you want to erase/overwrite it.
Once you have confirmed the action, the script will begin flashing your device.
After flashing has completed, you will be prompted to connect your device to WiFi.
With the Raspberry Pi, the device will first need to be connected to the local network through an Ethernet cable. While this works well on a home network, I did run into some issues when connected to a company network (which is expected; they don’t want devices just having free reign on their network). Luckily, you can connect the Pi to an HDMI display and get the local network address from that to manually connect via the commands
adb connect <ip address> adb shell am startservice \ -n com.google.wifisetup/.WifiSetupService \ -a WifiSetupService.Connect \ -e ssid <Network_SSID> \ -e passphrase <Network_Passcode>
or you can connect a keyboard/mouse to the Raspberry Pi and use the GUI to manually enter in a WiFi SSID and password.
With your device connected to WiFi, you should be all set to start doing some Android Things development. The new setup utility makes the first step of creating your IoT products that much easier, and the next step would be actually creating a project. You can find documentation about Android Things through the official documentation, and inspiration through Hackster.io's Android Things project page to see what others have created with the platform. Good luck, and have fun :)