Coder Social home page Coder Social logo

ligen1996 / android-studio-builder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vuksa/android-studio-builder-1

0.0 0.0 0.0 150 KB

Docker container that builds Android Studio from sources

License: BSD 3-Clause "New" or "Revised" License

Shell 82.93% Dockerfile 17.07%

android-studio-builder's Introduction

team project

Third-Party Licences

By building this docker image you confirm that you accept Google's Android SDK and Android NDK licenses (https://developer.android.com/studio/terms).

Prerequisites

  • Linux machine (other OS also probably fine, but some tuning might be needed)
  • At least 50 GB free disk space
  • Latest and greatest Docker (18.0 or newer)

Step-by-step guide (for Linux)

  1. Clone this repository, and navigate inside the checked out directory
  2. Setup AOSP_ROOT environment variable. If you have AOSP sources downloaded - you can use them. Otherwise just create an empty folder and make AOSP_ROOT pointing to it. We will download sources later.
export AOSP_ROOT=</path/to/parent/of/"tools"/dir, or empty dir>
  1. Run the script
sh ./rundevmode.sh
  1. it will build docker image
  2. it will start docker container and will make a 3-4 folders shared between the docker and the host (e.g. $AOSP_ROOT, ~/.cache/bazel, ~/.cache/.m2 and ~/.cache/.gradle)

image.png

Now when we have docker container up and running, all the following commands should be executed inside Docker (not inside the host):

  1. $AOSP_ROOT is now mounted to /aosp/src inside the container. If $AOSP_ROOT was pointing to an empty directory, this is good time to download the sources. Sources will be downloaded to /aosp/src inside the container, and will be availabe at $AOSP_ROOT on the host.
cd /aosp/src && sh /aosp/builder/scripts-vcs/runrepo.sh
  1. Apply patches to the sources otherwise they won't compile
cd /aosp/src && sh /aosp/builder/patches/runpatches.sh
  1. Build Android Studio dependencies with bazel
cd /aosp/src && /aosp/src/tools/base/bazel/bazel build //tools/adt/idea/android:artifacts

image.png

Now go back to the host, open $AOSP_ROOT/tools/adt/idea in IDEA and click rebuild project

  • Use Android Studio run configuration to run Android Studio from sources.

Understanding the guide

Google builds Android Studio with Bazel (Blaze). They have a huge monorepo which contains a lot of sources and binaries. Some parts of this monorepo are visible from https://android.googlesource.com/, others are private. To checkout sources special tool is needed - repo. Sources contain not only Java/Koltin code, but also native C/C++ code, and one needs Android SDK and Android NDK to build it properly.

The solution is as follows: sources are shared between the host and docker container. Sources can be loaded to IDEA on the host, but there are a few JARs which should be generated by Bazel. In order to build them we create Docker container and run Bazel there.

Sources are downloaded with a repo tool. Docker container has a copy of repo inside. repo is smart enough to ignore unreachable repositories. Usually it is safe to ignore warnings that some remote repository is not found.

Sources from AOSP are built with Bazel. Original Bazel files reference some other files from private repositories. Patches (runpatches.sh) are removing these dependencies. Additionally, patches are removing private modules (e.g. google-appindexing) from modules.xml, which do not compile anyway.

Sharing the files between the Docker and the Host is yet another challenging task. Files on the host are owned by $USERNAME. which has its own id and gid. As part of the container setup dev-local/setuplocaluser.sh is executed that creates a user inside the docker. If you have problems with permissions on files - this is the first place to check.

android-studio-builder's People

Contributors

andrei-kuznetsov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.