Failed to resolve: 'de.greenrobot:eventbus:2.4.0'

4.7k views Asked by At

I am using Android Studio but when I try to add: compile 'de.greenrobot:eventbus:2.4.0' to my dependencies in my app component's gradle file, I get a banner: Project sync succeeded. Open the 'Messages' view to see the errors found. And in the messages pane, it shows the error message:

Error:(28, 13) Failed to resolve: de.greenrobot:eventbus:2.4.0
<a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

When checking EventBus on github I find that the latest version does exist on maven central.

Could it be an android studio misconfiguration or something?

Here is the rest of the dependencies that works fine (without the event bus dependency):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.aiesec"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 1
        versionName "0.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'de.greenrobot:eventbus:2.4.0'
}
1

There are 1 answers

1
reubenjohn On BEST ANSWER

This is embarrassing but the issue was that the gradle file (in my project's root/base folder) did not have mavenCentral in it's allprojects list of repositories!

So adding the mavenCentral() to the repositories of allprojects as shown below fixed the gradle sync errors for me:

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

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

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}