我正在使用Android Studio但是当我尝试在我的应用组件的gradle文件中向我的compile 'de.greenrobot:eventbus:2.4.0'
添加:dependencies
时,我得到一个横幅:项目同步成功。打开“消息”视图以查看发现的错误。在消息窗格中,它显示错误消息:
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>
在github上检查EventBus时,我发现maven central上存在最新版本。
可能是Android工作室配置错误还是什么?
以下是其他依赖项工作正常(没有事件总线依赖):
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'
}
答案 0 :(得分:10)
这很令人尴尬,但问题是gradle文件(在我项目的root / base文件夹中)的allprojects
存储库列表中没有mavenCentral!
所以将mavenCentral()
添加到repositories
allprojects
,如下所示为我修复了gradle同步错误:
// 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()
}
}