Build Overview‎ > ‎

Building Android Studio

Set up IntelliJ for developing Android Studio

  • Download the latest IJ community edition.
  • Add a JDK to it: Project Structure | SDK's | Add new JDK with the exact name "IDEA jdk". (Note that this SDK should be a standard JDK, NOT an "IntelliJ Platform Plugin SDK")
    • Please use JDK 1.6, since we are still supporting the IDE running on Java 6. You can use later versions of the JDK, but you may accidentally access APIs that are not available in 1.6, so if you plan to contribute changes back, make sure you are using JDK 1.6 as your IDEA jdk.
  • If you are not on Mac OSX, also add tools.jar from your JDK to the IDEA jdk's classpath. (located in <JDK Path>/lib/tools.jar).
  • (Note: You must have the Groovy and UI Designer plugins enabled. They should be, by default, but if you run into compilation errors in .groovy files that might be the issue.)

The Studio Source Code

After following the download instructions (here), you will have the Android plugin source code under tools/adt/idea, the IntelliJ IDE base in tools/idea/, and a lot of shared libraries in tools/base/.

Working and building from within IDEA
In IntelliJ, open the Android Studio project by choosing Open Project and selecting the folder tools/idea/. You can now compile and run and debug the project.

Building from the command line

$ cd tools/idea
$ ant

Look for the artifacts in out/artifacts.

Running Unit Tests
You can run individual tests (or the AllTests suite) from within the IDE. To run the tests on the command line, invoke
$ cd tools/idea
$ ant test

We're also working on GUI tests. These require a display (and take over your mouse and keyboard). To invoke these, run
$ cd tools/idea
$ ant guiTests

If you're attempting to run unit tests in the IDE and you get a "File access outside allowed roots" exception failure, you'll need to set the following property in your unit test run configuration (it's easiest to set this in the default unit test configuration) :

NO_FS_ROOTS_ACCESS_CHECK=true

Typical issues

  • "When building the firs time I get an error: java: package com.sun.source.tree does not exist " ==> Make sure to add tools.jar to the "IDEA jdk" configuration, as explained above. This is easy to miss. To fix it: File > Project Structure > SDKs > "IDEA jdk" > classpath > + > select C:\Program Files\Java\(jdk_version)\lib\tools.jar.
  • If you are trying to load and run the IDE project on Windows with Cygwin, you may get a "java.lang.UnsatisfiedLinkError: C:\cygwin64\home\...\tools\idea\bin\win\jumplistbridge64.dll: Access is deined" exception. To fix this, you need to open the various .exe and .dll files in the tools/bin/win folder and give the execute permissions. Open the folder in Windows Explorer and select one of the executable files and right click on it to open the Properties dialog. Click on the Security tab, click on the Edit... button and grant execute permission. Hit OK. Repeat for all the necessary .dll files.
  • You can also open a command prompt as Administrator and use the following command:
icacls C:\cygwin64\home\Android\aosp\tools\idea\bin\win\* /grant Everyone:(RX)