# How to set up flatbuffers in Android Studio - Gradle?

Just switching over from Eclipse to Android Studio. I think I'm supposed to use Gradle to automatically download dependencies from the web. Sounds great, but I can't get it working with anything, in particular Google's flatbuffers.

So I found the link on the Maven repository, and I think I'm supposed to do something with the following:

// https://mvnrepository.com/artifact/com.github.davidmoten/flatbuffers-java
compile group: 'com.github.davidmoten', name: 'flatbuffers-java', version: '1.3.0.1'


But the comments in my project's Gradle (which is supposed to be a library by the way - but that's another story...) says I should not place my "dependencies here" (see below)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

delete rootProject.buildDir
}


So what am I supposed to do? I've heard of "modules" - so I could load flatbuffers in as a module?

I was updating the wrong build.gradle. I was updating the gradle of the package within the "app". So having updated my build.gradle file (Module: app) to include the following last dependency:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile group: 'com.github.davidmoten', name: 'flatbuffers-java',
version: '1.3.0.1'
}


it works nicely. Beginning to like AS now... hehe.

UPDATE

Been porting my stuff over to Android Studio today. I'm a total convert - very good and much easier than Eclipse.