Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Development Environment on an ARM Chromebook?

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.

like image 569
Mapsy Avatar asked Dec 20 '16 04:12

Mapsy


People also ask

Can you do Android development on a Chromebook?

Being able to run Android apps on a Chromebook is great, it gives users access to the vast Android ecosystem offerings and it gives Android developers the opportunity to reach Chrome OS users. Developers should make a point to verify their apps on different form factors, since this will help improve users' experiences.

Can you do app development on a Chromebook?

Here's a running list of apps from the Chrome Web Store that can help you develop on your Chromebook or Chromium OS device: Chrome Dev Editor (Developer Preview) - Editor for building Web Apps and Chrome Apps, in JavaScript or Dart. CDE also supports Git and Polymer development.

Can you run ADB on a Chromebook?

Important: Once you turn on ADB, it's available to all accounts on your Chromebook.

Can Chrome OS run on ARM?

ChromeOS Flex does not support ARM architecture. To provide a reliable and predictable experience, Google has tested and optimized many of the world's most popular models of Windows, Mac, and Linux devices.


1 Answers

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.

like image 115
Mapsy Avatar answered Sep 27 '22 17:09

Mapsy