“I always say, 'This will be my last 'Metal Gear.'” Hideo Kojima

How to add HoloEverywhere to your projects in Android Studio (until 0.3, git submodules)

Welcome to my new blog!

Hi! Why do you have a new blog?

Good question. After DAYS of mental block with this issue, I’ve finally decided to start a blog so I can take note of solutions to problems for future reference. And, at the same time, may it also serve to help other people.

UPDATE: Sometimes you need to configure Android Studio after going through the process of this tutorial. Use "Project Structure" to import HoloEverywhere modules and include them as dependencies (the same way as we have them on gradle files) using the GUI.

So, getting to the main subject…have you tried to use Android Studio lately? It’s still in early preview status, but it is really stable. I decided to start using it months ago so I can slowly learn how to use it. It’s the future, they say. After a while, I discovered that Google has introduced many new features to Android development. Gradle is one of them. It is described by Wikipedia as a “project automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based DSL instead of the more traditional XML form of declaring the project configuration”. Well, basically it’s a more script-oriented automation tool than Ant or Maven.

Now, if you try to create a new project in Android Studio it will “force” you to use Gradle by default. Your new project will include gradle build files. It happened to me. And I then realised that I must learn Gradle too. And then, I realised that I need to use libraries (HoloEverywhere). Dragons ahead, I thought.

I found dragons also! What to do?

Google it!

You’ll find no clear answer :( But after many hours of fighting, it seems I found a solution. My project now builds on command line and also does on Android Studio!

OK, let’s go. Create a new project using Android Studio wizard. Then, close AS (don’t use it to edit the files as described below) and take a look at the project’s folder. You have to copy your libraries there, at the root. It will look like this:

- HoloEverywhere
--  +addons
--  +application
--  +demo
--  +library
- Project
-- src
-- build.gradle
-- Project.iml
-  build.gradle
-  settings.gradle

If you use git, initialize a repo like this:

git init 
git submodule add https://github.com/Prototik/HoloEverywhere.git

After this, if you want to use ActionBarCompat instead of ActionBarSherlock, edit the .gitmodules file so it looks like this:

[submodule "HoloEverywhere"]
    path = HoloEverywhere
    url = https://github.com/Prototik/HoloEverywhere.git
    branch = abc

Finally, pull data:

git pull
git submodule update --init

Done! What more?

Let’s configure Gradle. First I recommend you to read the basics from gradle.org documentation so you can understand a bit how Gradle works. Go read, I’ll wait here.

Finished? Nice. For this project, we need the core HE library and also the preferences addon. Also, we want to use ActionBarCompat instead of ActionBarSherlock.

For using ABS you may just act as we'll do for HE.

Go to your project root and edit settings.gradle this way:

// Include main project and needed libraries
include 'library', 'addons-preferences', ':Project'

// Define global folder references
project(':library').projectDir = new File(settingsDir, 'HoloEverywhere/library')
project(':addons-preferences').projectDir = new File(settingsDir,'HoloEverywhere/addons/preferences')

Whatever you put on this file will apply for both your project and HE (or any other library/project you have on your root folder). As you can see, we have defined two “virtual” projects pointing to the actual folders where libraries are.

It may work without those definitions, but I haven’t managed to make it work without them. If you did it, please tell me how. I’m still a Gradle noob.

Finally, edit your app’s build.gradle file (the one at ProjectRoot/Project/ build.gradle) to look like this:

apply plugin: 'android'

repositories {

android {

    compileSdkVersion 18
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 18

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            resources.srcDirs = ['src']
            res.srcDirs = ['src/main/res']


dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.android.support:appcompat-v7:18.0.+'
    compile project (':library')
    compile project (':addons-preferences')

And that’s it! Open Android Studio and your project should now be correctly configured and also build flawlessly : )

Hope it helped someone.