3

I try to embed Otto library, which exists at the Maven Central.

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

    }
}

apply plugin: 'android'

dependencies {
    compile 'com.google.android.gms:play-services:4.0.30'
    compile 'com.android.support:support-v13:19.0.0'
    compile 'com.squareup:otto:1.3.4'
}

But I get the exception:

A problem occurred configuring root project 'sample-project'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':_DebugCompile'.
      > Could not find com.squareup:otto:otto:1.3.4.
        Required by:
            :sample-project:unspecified

I tried to refresh dependencies(gradle --refresh-dependencies) but it doesn't help.

eleven
  • 6,779
  • 2
  • 32
  • 52

2 Answers2

10

You need to tell gradle where to find it.

repositories {
    mavenCentral()
}

Note that the existing repositories { ... } inside buildscript { ... } is only to configure the repositories for the build classpath itself, not your project, so put this new element just under apply plugin ...

Xavier Ducrohet
  • 28,383
  • 5
  • 88
  • 64
1

I believe what you're missing is Tools->Android->Sync Project with Gradle Files. I tested your code above and it worked just fine for me.

Hope this helps.

Grimeh
  • 161
  • 1
  • 12
  • I don't use Intellij(AndroidStudio) or Eclipse. – eleven Dec 12 '13 at 10:06
  • Sorry, my mistake. I assumed you did since it looked much like an error message I've seen in IntelliJ, also trying to get Gradle dependenices to work properly. So if you're not using Android studio or Eclipse, I assume you're compiling etc from the command line? – Grimeh Dec 12 '13 at 14:04