Getting started with Android Things

Alex Simonescu
Published in
4 min readDec 17, 2016


Internet of Things was something that amazed me since the beginning. Just think of it, automatize all your house, that was the first thing I thought when I first red about IoT. Then Arduino appeared! That was my first and favorite shield device in this world of connected devices but some recent news from Google may change that favorite one..

On December of 2016, Google announced Android Things. A modified version of the Android all we know, for IoT devices.

An excerpt from the official documentation:

Android Things extends the core Android framework with additional APIs provided by the Things Support Library. These APIs allow apps to integrate with new types of hardware not found on mobile devices.

Next step after reading about Android Things was going to Amazon webpage and order one Raspberry Pi 3 model B. Already had the first Raspberry on market, but Things seems to be only compatible with the Pi3 model.

My configuration was the following:

  • Mac OS with El Capitan
  • 32GB SD card
  • Raspberry Pi 3 Model B
  • HDMI cable
  • A real screen with HDMI support or a display for Raspberry
  • Ethernet cable and router

Note: You can also use the Vysor Chrome app as a substitute for a real screen.

Raspberry is not mandatory for Android Things, Intel Edison is also supported among other to come.

Flash SD card with Android Things

Insert the SD card into your Mac, go the the Disk Utility tool and format the SD card in FAT format. Now remove it from your computer, since it will be easier to distinguish the card’s name.

Use the “Erase” option to format your SD card
  1. Download the disk image from the official webpage.
  2. Unzip the downloaded image: unzip ~/Downloads/
  3. Open an Terminal and run: df -h
  4. Connect your SD card inside your computer.
  5. Run df-h again from the Terminal. A new device you should see: /dev/disk2s1 was mine but it could be different in your case.
  6. Unmount the partition so we will be allowed to overwrite the disk: sudo diskutil unmount /dev/disk2s1
  7. In the next step we will use a tool to record the Android Things image into the SD card, passing the name of the entire SD card disk. If the name from the previous step was disk2s1, the resulting name would be rdisk2.
  8. From Terminal: sudo dd bs=1m if=iot_rpi3.img of=/dev/rdisk2. This will record the image in the SD card. Be patience, the Terminal won’t show any progress, just wait until it’s done.
  9. Eject the SD card from Terminal: sudo diskutil eject /dev/rdisk3
  10. Insert the SD card into the Raspberry Pi and have fun!

Connect to Raspberry Pi with Android Things

Once you inserted the SD card into the Raspberry, plug the HDMI cable to the screen, and the ethernet cable to the router. I used the Mac’s usb port to power on the Raspi.

Now you should see the Android Things logo and an IP address bellow. Use that IP to connect to the device.

adb connect

You can check if you’re successfully connected using the: adb devices command.

Using the ethernet cable ends up being a bit messy, all those cables on your desk.. So let’s connect to WiFi:

adb shell am startservice \
-n \
-a WifiSetupService.Connect \
-e ssid MyWiFiSSID \
-e passphrase Secr3tPassw0rd

Once your Raspberry connects to your WiFi, you will be given another IP address associated to your wireless network card. Take a look at the Raspberry’s screen and connect with the new IP. Now you can remove that old ethernet cable. We’re wireless!

First project with Android Things

Create a basic project using Android Studio, no new tools, just our shiny IntelliJ base IDE.

As you will need to target a specific minimum version and add a support library, modify your build.gradle:

android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.alexsimo.things"
minSdkVersion 24
targetSdkVersion 25
// some lines were omitted}

dependencies {
provided '' // dependencies omitted

We need to add the Android Things dependency as provided, that way it will pick the library from the system.

Create a new activity and modify the AndroidManifest.xml with the following:

<manifest xmlns:android=""


<uses-library android:name=""/>

<activity android:name=".MainActivity">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.IOT_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>


The last intent filter is for Android Things to launch our application on boot.

From our activity we may now try to debug to see if it works:

public class MainActivity extends Activity {

private static final String TAG = MainActivity.class.getSimpleName();

@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
Log.d(TAG, "Hello Android Things!");

And we are done!! Next steps will be connecting some sensors and displays to the shield board, so stay tuned! Code for the article if published on this GitHub repository, probably all new stuff will go there.



Alex Simonescu

Software developer focused on Android, software craftsmanship, best practices, patterns, reactive programming and some more techie stuff.