Build Android Studio Source Code

If you haven’t already done so, download the Android Studio source code so that you have a local copy of the following projects:

  • Android plugin source code: <studio-master-dev>/tools/adt/idea
  • IntelliJ IDE base: <studio-master-dev>/tools/idea/
  • Shared library dependencies: <studio-master-dev>/tools/base/.

To learn how to build the Android plugin for Gradle from source, read The Android Gradle plugin.

Run Bazel

Note that this does not apply to AOSP currently Issue 126764883. The required binaries are checked in as prebuilts. You should ignore this section if building from AOSP.

In order to successfully build Android Studio from source, you’ll need to make sure that you’re able to run the revision-controlled executable of Bazel that's located in the <studio-master-dev>/tools/base/bazel/ directory:

$ cd studio-master-dev/
$ tools/base/bazel/bazel version
  Build label: …
  Build target: …

To make sure Bazel can execute Android Studio build tasks, try running the following command:

$ bazel build <studio-master-dev>/tools/adt/idea/android:profiler-artifacts

To learn more about running Bazel (including running tests), read Building Studio with Bazel.

Install prerequisites for Windows users

If you're on Windows, you need to complete the following steps before you build AS from the command-line:

  1. Install Python 2.7 or higher: Ensure you have Python installed on your windows machine, and the path to python.exe is added to your PATH environment variable. Note: It is recommend you use the 64-bit version, although the 32-bit version should work fine.

  2. Install msys2: When building Android Studio, Bazel expects to find msys2 installed at c:\tools\msys2\. Otherwise, you get a build error.

  3. Install Visual Studio 2015 build tools: Otherwise, you get a build error.

  4. Install Git for Windows: If you haven’t already done so, download and install Git for Windows (64-bit):

    1. Enable the option to Use Git from the Windows Command Prompt.
    2. Enable the option to Checkout Windows-style, commit Unix-style line endings.
    3. Add Git for Windows to your PATH environment variable.
    4. Configure Git to support long paths (that is, paths longer than 260 characters):
      C:> git config --global core.longpaths true
    5. Set the following PATH environment variables:
      C:> set PATH=%PATH%; %LOCALAPPDATA%\Programs\Git;%LOCALAPPDATA%\Programs\Git\Cmd;%LOCALAPPDATA%\Programs\Git\usr\bin;%USERPROFILE%\bin
  5. Download and install git-repo and include it in your PATH environment variable.

  6. Download the Android SDK. You can do this in one of two ways:

    1. Use the SDK Manager from a pre-installed version of Android Studio.
    2. Download the SDK command line tools, and then use the sdkmanager command line tool to download an Android SDK package.

Build Android Studio using IntelliJ

If you are interested in making changes to the Android Studio codebase and building the IDE from source, you can do so using IntelliJ. To begin, you need to first configure a new project from the Android Studio source code, as follows:

  1. Download and install the latest version of IntelliJ IDEA Community Edition.
  2. Open IntelliJ IDEA and create a new project.
  3. When prompted to select the source directory for your project, select <studio-master-dev>/tools/idea/ and click OK.
  4. Keep clicking Next until you are prompted to select the project SDK.
  5. Point IntelliJ to your local JDK, as follows:
    1. Select IDEA jdk from the left pane.
    2. While IDEA jdk is highlighted, click Add new SDK (+) > JDK. Note: The SDK you add should be a standard JDK, NOT an “IntelliJ Platform Plugin SDK”.
    3. Navigate to where you downloaded the Android source code and select the JDK package included in prebuilts/studio/jdk/
    4. If you are on Linux or Windows, also add <jdk-path>/lib/tools.jar to the IDEA jdk classpath.
  6. Keep clicking Next until IntelliJ creates your project.
  7. After the IntelliJ finishes creating your project, click Build > Rebuild Project from the menu bar.
    • If you see issues compiling .kt files, make sure that you've installed the Kotlin plugin
  8. Select AndroidStudio from the Configurations pulldown menu near the top right of the IDE.

Note: If you run into issues compiling *.groovy files, make sure you enable the Groovy plugin.

To build Android Studio, click the Run button (which looks like a green ‘play’ button) near the top right corner of the IDE.

Building from the command line

To build Android Studio from the command line, run the bash shell as Administrator and execute the following commands:

$ cd studio-master-dev/tools/idea
$ ./

Windows users: to build Android Studio from the command line from a Windows machine, run Command Prompt as Administrator and execute the following commands:

$ cd studio-master-dev/tools/idea
$ ant

You should find compressed build artifacts in studio-master-dev/out/artifacts/. To run the version of Android Studio you just built, extract the artifact for your OS, and then run either /bin/ or \bin\studio.exe from the extracted directory.

Common issues

  • Error: java: package com.sun.source.tree does not exist: Make sure to add tools.jar to the “IDEA jdk” configuration, as explained above in Build Android Studio using IntelliJ.

  • java.lang.UnsatisfiedLinkError: C:\cygwin64\home...\tools\idea\bin\win\jumplistbridge64.dll: Access is denied: You may get this exception if you are trying to load and run the IDE project on Windows using Cygwin. To fix this issue, grant execute permissions to necessary files by opening a command prompt as Administrator and running the following command:

    icacls C:\cygwin64\home\Android\aosp\tools\idea\bin\win\* /grant Everyone:(RX)

    Alternatively, you can navigate to the tools\bin\win\ directory and perform the following actions for each .exe and .dll file:

    1. Right-click on a file.
    2. Select Properties to open a dialog.
    3. Click on the Security tab.
    4. Click Edit.
    5. Enable execute permission.
    6. Click OK.