Building and linking from sources

The Blockly binaries provided in the JCenter repository only reflect the latest master branch of Blockly. If want to use another branch in your app, such as Blockly's latest develop branch, you will need to build and link Blockly's .aar files.

The major steps are:

  1. Download the sources
  2. Build the libraries
  3. Update the app's dependencies

Get the Code

First, download the source code from GitHub. When working from the develop branch or making changes to the code, it is highly recommended you clone blockly-android using git:

git clone
cd blockly-android/

By default, git will clone the develop branch. If you wanted another branch, create a local tracking branch for it.

git checkout -t origin/master

Build the Library

In Android Studio, open the new blockly-android directory. You should should see four modules in the project, the first of which is blocklydemo. Build and run blocklydemo to build and verify your source copy.

Once built, you will find the following library files:

  • blockly-android/blocklylib-core/build/outputs/aar/blocklylib-core-release.aar
  • blockly-android/blocklylib-core/build/outputs/aar/blocklylib-core-debug.aar
  • blockly-android/blocklylib-vertical/build/outputs/aar/blocklylib-vertical-release.aar
  • blockly-android/blocklylib-vertical/build/outputs/aar/blocklylib-vertical-debug.aar

The core files include the model and controller classes, and base classes for the views. The vertical files include the vertically stacking blocks view, defined by the VerticalBlockViewFactory and associated view classes. You will include at least one of each in your project.

If you find these files, you can close the blockly-android project in Android Studio.

Update Application Dependencies

In your application project, open the "Project Structure..." dialog, under the "File" menu. Make sure the app module includes the required support library dependencies:


Remove the and libraries from your project. These are the pre-built binaries from JCenter that will be provided by the new .aar files.

Add a module to the project using the '+' button in the Project Structure dialog. Choose the "Import .JAR/.AAR Package" module template, and select blocklylib-debug.aar or blocklylib-release.aar from the blockly-android project directory. Then, in the app module dependencies, add the new module as a module dependency.

Screenshots of adding a module in Android Studio.

Importing these .aar files will copy them into the project directory at the following location(s):

  • MyBlocklyApp/blocklylib-core-debug/blocklylib-core-debug.aar
  • MyBlocklyApp/blocklylib-core-release/blocklylib-core-release.aar
  • MyBlocklyApp/blocklylib-vertical-debug/blocklylib-vertical-debug.aar
  • MyBlocklyApp/blocklylib-vertical-release/blocklylib-vertical-release.aar

If at a later date you wish to update the Blockly library in your project, just replace the copies at these locations with newer versions.

You can add both the debug and release version .aar files, if you want full debug info in only your app's debug build. If you do, make sure the scopes in the app module dependencies are "Debug compile" and "Release compile", respectively.

Screenshots of the Project Structure dialog in Android Studio, with all module dependencies configured.