0

我正在尝试在我的项目中包含 Otto 库,但出现此错误:

> Could not resolve all dependencies for configuration ':maptest:_debugCompile'.
> Could not find com.squareup:otto:1.3.4.

我试过清理项目,运行工具-> android->使用 gradle 文件同步项目,但这给了我同样的错误。

我的 build.gradle 如下:

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

apply plugin: 'android'

android {
compileSdkVersion 18
buildToolsVersion "18.0.1"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
    }
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.0.1'
    compile 'com.google.android.gms:play-services:4.1.32'
    compile 'com.squareup:otto:1.3.4'
}
4

2 回答 2

2

您应该添加 maven 中央存储库,以便 gradle 知道在哪里搜索库。

repositories {
    mavenCentral()
}
于 2014-01-27T09:13:43.483 回答
1

您是否将 Otto 库导入Android Private Libraries? 以这种方式尝试清理项目:项目->清理...

你可以看看这个

于 2014-01-27T09:18:36.647 回答