Question

When Android Studio creates a project, the top-level build file has two repositories definitions, one inside buildscript and another inside allprojects.

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

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

Where must I add another repository and why?

I think that repository inside buildscript is here to add the gradle plugin dependency, but I'm not sure...

Someone could clarify me, please.

Thank you!

Était-ce utile?

La solution

The buildscript is for dependencies of your build files. You want to add a repository there if, for example, a task in your build.gradle needs a plugin that is not found in the standard Gradle distribution, like a gwt wrapper.

The allprojects is for dependencies needed by your application, like log4j, Guice, Guava and so on.

Also, be warned that using mavenCentral for retrieving dependencies is a bit discouraged, because if the network is down or if the project is removed from their repositories, you won't be able to build your project anymore

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top