Android Development Environment on an ARM Chromebook?

4.3k views Asked by At

I've tried multiple times to install and use Android Studio on an ARM Chromebook (C100P), but the installation always fails with the failed to run mksdcard tool error. I've read that this happens because Android Studio depends on native binaries that aren't compatible with the ARM processor architecture; even after attempting various hacks or just trying to use the libraries alone, I am still not able to setup Android Development Environment on my ARM Chromebook.

1

There are 1 answers

0
Mapsy On

Native Conclusion:

I've come to the conclusion that you really just can't. Android's compilation tools depend upon native libraries; specifically, lib32stdc++6 and lib32z1. These depend upon 32-bit Intel binaries, so there's no chance of executing these instruction words on an ARM processor (not even with i386 multiarch support) until Google starts making some changes.

Luckily, I'm here to present a workaround. We're going to delegate computation to a virtual machine; one that is compatible with these binaries. It'll be free and secure, so you don't have to worry about who gets access to your source code. We're going to achieve this using the Google App Engine.

Workaround:

I'm going to start this tutorial assuming we're using a fresh installation.

  1. First, download the latest Crouton installer so we have a full-fledged Ubuntu distribution to work with. Within the Chromebook shell (Ctrl + Alt + T and enter shell), execute the installer. I chose to install the latest version of Ubuntu, Xenial, without a window manager. I also enabled integration with the Crouton Chrome extension to enable a shared clipboard.

    sudo sh ~/Downloads/crouton -r xenial -t touch,audio,keyboard,extension

  2. Next, enter-chroot into Ubuntu, and install curl and python:

    sudo apt-get update sudo apt-get install curl python git

  3. Use curl to fetch the Google Cloud SDK. You may extract it to the default location ~/google-cloud-sdk, or another directory you'd like.

    curl https://sdk.cloud.google.com | bash

  4. Navigate to your Google Cloud SDK directory and execute the installer. Allow it to update your $PATH variable and enable updates to be made to your ~/.bashrc file.
  5. Restart the shell. Use logout or exit, then re-enter using sudo enter-chroot. This enables your Google Cloud SDK installation to be accessible from the command line.
  6. Login to the Google Cloud SDK using your associated Google Account using gcloud auth login. This will require you to do two things; first, enable the SDK to access your Google Account. Secondly, you'll be required to copy a verification key from your browser at a supplied web address, which you'll need to paste back into the console.
  7. Log into the Google Cloud Console.
  8. Create a new Project, e.g. android-compile-worker, and within that project create a new repository, e.g. compilation-tools. We'll install the Android SDK Tools within this repository. When we do this, we're in effect placing them inside a virtual machine that can correctly interpret the native 32-bit binaries it uses.
  9. Launch the Google Cloud Console's terminal in your web browser. Next, make a clone of your repository within both the Google Cloud Console terminal and your local Chromebook shell.

    gcloud init

    gcloud config set project project-name-here

    gcloud source repos clone repo-name-here

  10. Within the Google Cloud Console terminal, move to your created repository and download and unzip the latest version of the Android Tools SDK. wget https://dl.google.com/android/repository/tools_r25.2.3-linux.zip unzip tools_r25.2.3-linux.zip
  11. Now we've successfully extracted the Android SDK tools onto a Google Cloud machine; export a PATH variable to this location to enable it's utilisation. export ANDROID_HOME=path/to/unzipped/tools
  12. Install those pesky binaries we couldn't use on our laptop. Since this installation is lost when your instance times out, you may append the commands to your .bashrc to persist the installation across new server instances. sudo apt-get install lib32stdc++ lib32z1
  13. Back on your Chromebook, install the following utilities to enable Android device programming. sudo apt-get install android-sdk-platform-tools-common android-tools-adb android-tools-adbd android-tools-fastboot

Design Flow

And that's everything! If you've followed these steps correctly, you'll have successfully configured one of Google's virtual machines for Android compilation. Via the Google Cloud Console terminal, it's possible to add Android platform support for various API Levels you wish to compile for.

Here, we add API Level 25, and the Android Support Repositories, as follows:

./android update sdk --filter android-25 --no-ui

./android update sdk -u -a -t android-25

./android update sdk --all --filter "extra" --no-ui

Now, using git pull origin master and git push origin master, you can upload code developed on your Chromebook onto the repository where it may be compiled by the Android SDK. You can do this by executing the project's local gradlew file, i.e. ./gradlew build.

Once compiled, you may pull the generated binaries back onto your development machine and configure connected Android devices using the Android Device Bridge (adb), using adb install path/to/apk.