Manage cookies

We use cookies to improve our services. Read more about how we use cookies and how you can refuse them.

The necessary cookies help to make the website work properly.

Anonymous statistical cookies help to understand how visitors use the website.

  • Android Things
    5 min | 3729

    #Tutorial: Getting started with Android Things

    Android Things | 5 min | 3729

    As the title says, this is a getting started with Android Things. It should be my first post, but, it's better now than never. I'm posting this to summarize the steps to install Android Things on your Raspberry Pi.

    Google announced Android Things on December of 2016. It's a modified version of the Android that we all know, but for Internet of Things (IoT) devices. The architecture of the SDK is described in the following figure:

    Android Things Architecture
    Fig.: Android Things SDK architecture (Source: Google)

    As you can see, the core Android framework (the level below the Apps) is extended with additional APIs provided by the 'Things Support Library' (in orange). These APIs enable the integration of the apps with the new IoT devices.

    Android Things is compatible with many developer kits. A list can be found here. Besides the NXP and the discontinued (Edison and Joule) Intel boards , the Raspberry Pi 3 Model B is also compatible.

    Android Things is still in development phase (-devpreview), which means that there are many (un)known issues. A list of known issues can be found here together with the release notes, others can be found or reported here (search "Android Things" or your something related to your problem).

    How to get the Android Things image?

    The first versions of Android Things were available to download as a zipped image using a link. There was no connection between you and the downloaded image. Nowadays you get the zipped image using the Android Things Console and you need to have a Google account and create an app image. The good thing about it, you can flash the image on many devices as you want, and you can update your application using the Console with only one click!

    The steps to download the zipped image are the following:

    1. Go to: Android Things Console and sign in using your Google credentials
    2. Click on: Create a new Product
    3. Go to: Factory Image
      • Select: Empty Bundle (if you don't have any app yet) and the Android Things v. e.g. OIR1.170720.017 for 0.5.1-devpreview
      • Click on: Create Build Configuration
    4. Make a coffee or just wait a couple of minutes until the download of the .zip file containing the .img file starts
    5. You get the zipped image, unzip it using e.g.:

    You shouldn't install an image that you find on the Internet without knowing its source. You should already known now that the image can contain applications and as I said, it can be updated using the Android Things Console. The applications/updates are installed without asking you for permissions. That means, if someone want to install a backdoor, or an access to your private network from outside, this is possible!

    How to flash the image?

    1. Find an 8 GB or larger microSD card and insert it into your development computer
    2. Unzip the .zip file (you need about 4GB), and flash the .img using:

    Click here for more info


    1. Insert the flashed microSD card into your Raspberry Pi 3
    2. Connect an HDMI cable to an external display or use the Raspberry Pi Display
    3. Connect an Ethernet cable
    4. Connect an USB cable and power the board
    5. The Android Things Launcher should show information on the display, including the IP address

    How I connect my development computer to the Raspberry Pi?

    You need to use the Android Debug Bridge (adb). This is included if you've already installed Android Studio, otherwise you can download and install the last version from here. On Windows, I needed to modify the Environmental Variables to include: C:\Users\<your-username>\AppData\Local\Android\sdk\platform-tools

    Steps to modify the Environmental Variables on Windows:

    1. Press Windows + Pause keys together (System dialog should open -Control Panel\All Control Panel Items\System-)
    2. Click on Advance system settings on the left panel
    3. Go to Advanced tab
    4. Click on Environmental Variables button
    5. Search for Path in System Variables (the lower panel)
    6. Click on Edit, then New
    7. Type the adb file location (Usually: C:\Users\<your-username>\AppData\Local\Android\sdk\platform-tools -change <your-username> for the correct path)

    You can skip these steps, but then you need to type the full path to adb everytime you need to use it.

    To connect to the Raspberry Pi you need to:

    1. Open a cmd on Windows or Terminal on Linux/Mac
    2. Then, type (change <ip-address> to the IP displayed on your external display)
      $ adb connect <ip-address>
      connected to <ip-address>:5555

      You are then connected to Android Things, using adb shell you can access to the Android shell.

    Connecting to Wifi

    On the Raspberry Pi, you can use the WiFi to connect to your private network router and skip the Ethernet cable, or to connect to another WiFi.

    1. Open a cmd on Windows or Terminal on Linux/Mac
    2. Then, type (change <WiFiSSID> and <Secr3tPassw0rd> for the right values):
      $ adb shell am startservice \
       -n \
       -a WifiSetupService.Connect \
       -e ssid <WiFiSSID> \
       -e passphrase <Secr3tPassw0rd>
      or in one line:
      $ adb shell am startservice -n -a WifiSetupService.Connect -e ssid <WiFiSSID> -e passphrase <Secr3tPassw0rd>

    Known-Issues that I have/had (September 2017):

    1. Don't use Android Things DP 0.5.0. It simply doesn't work! It has too many bugs here are some that I described.
    2. Android Things DP 0.5.1:

      • it has some issues with Bluetooth. I cannot get the SensorTag-Things to work. It crashes in different positions! I think, it is a problem of Android O. I have a Nexus 5X and after updating it to Android O, I have problems with Bluetooth and my devices (e.g. SensorTags, UPRIGHT-GO) are not found.
      • it has problems with the SPI unit, after stopping the application in debugging mode, and starting it again, I get the following error:
      Unable to access SPI device android.os.ServiceSpecificException: SPI0.1 driver failure (code 5)

      Rebooting the Raspberry Pi using adb shell reboot (or un-plugin and plugin the power again) helps.

      The issue was reported here.

      • it has storage management problems too. After using the debugger and the application crashes too many times. I was not able to debug the app any more, I got the error Session 'app': Error Installing APK. Getting into the shell and typing df -h the /dev/fuse was used up to 96%. The /data/misc/crash_reporter/crash folder increased its size not allowing to install new applications. You can open a cmd or Terminal and type the following to resolve the problem (or you can flash the image again -not recommended):
      adb connect <ip-address>
      adb shell
      cd /data/
      du -h > /storage/emulated/storage.txt    # du (disk usage) reports the size of the directories
                                                 # this allows to check if the folder crash_reporter is the problem
      cat /storage/emulated/storage.txt       # read the written file
      rm -r /data/misc/crash_reporter       # deletes the folder

      The issue was reported here.

    Useful links

    Developer KitsAndroid Things compatible IoT devices
    Android Things Consoledownload Android Things image
    issuesknown issues per release
    issue trackerissues tracker and report
    7-ZIPunzip the .zip on Windows
    The Unarchiverunzip the .zip on Mac
    Win32DiskImageflash the image using Windows
    dd commandflash the image using Linux
    dd commandflash the image using Mac
    flashing the imagefor more info
    Android Debug Bridge (adb)download the adb to connect to Raspberry Pi
    Android Studiodownload Android Studio to write, debug and build Android applications