Q:

How can I use repositories in my module's build.gradle not in Top-level(Project's) build.gradle?

For example, when I use the 'activeandroid', I must make two paces:
1) In my Project's build.gradle(Top-level build.gradle),add
repositories {
    jcenter()
    // ActiveAndroid
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

2) In my module's build.gradle, add
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'

But can I add the repositories in my module's build.gradle ?
By the way, when I did that I got many errors, cannot build successfully.

A:

This worked for me, after wrapping in the root project clause.
rootProject.allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}

dependencies {
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}

A:

Yes you can do it.
apply plugin: 'com.android.application'

repositories {
    jcenter()
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' 
}

Don't confuse the repositories block with the repositories inside the buildscript block.

