André Ricardo André Ricardo - 1 month ago 5x
Android Question

add maven repository to build.gradle

I added a custom maven repository to build.gradle in Android Studio but the dependency is not being found

Maven repository and dependency

<name>Public AChartEngine repository</name>



buildscript {
repositories {
maven {
url ""
dependencies {
classpath ''
apply plugin: 'android'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'

android {
compileSdkVersion 19
buildToolsVersion "19"

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']

// Move the tests to tests/java, tests/res, etc...

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.

Error message in Android Studio:

A problem occurred configuring root project 'My-MobileAndroid'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':_DebugCompile'.
> Could not find org.achartengine:achartengine:1.2.0.
Required by:

What am I missing in build.gradle?


You will need to define the repository outside of buildscript. The buildscript configuration block only sets up the repositories and dependencies for the classpath of your build script but not your application.