Android studio找不到:com.getbase:floatingactionbutton:1.3.0

时间:2014-12-18 16:27:04

标签: android-studio

我正在尝试使用已经存在的android项目运行我的gradle文件。我对此应用程序的唯一错误是Failed to find: com.getbase:floatingactionbutton:1.3.0。下面是我的gradle文件。有什么东西需要改变才能让它发挥作用吗?

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

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:appcompat-v7:21.+'
    compile 'com.google.android.gms:play-services:6.5.+'
    compile 'com.getbase:floatingactionbutton:1.3.0'
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    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...
        instrumentTest.setRoot('tests')

        // 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.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

如果您需要其他信息,请与我们联系。提前谢谢!

2 个答案:

答案 0 :(得分:2)

根据http://search.maven.org/#search%7Cga%7C1%7Cfloatingactionbutton在Maven Central上搜索该库存在,所以我认为问题可能是您没有在构建脚本中添加repositories语句以让它解决依赖;你在buildscript块中获得的只是解析构建系统插件,而不是构建依赖关系。我知道这令人困惑。在顶层添加此块:

repositories {
    mavenCentral()
}

我还假设您的项目具有平面目录结构和单个 build.gradle 文件;当Android Studio通过向导创建项目时,它使用带有多个 build.gradle 文件的嵌套目录结构,并且它通常会在顶级构建文件中添加样板文件,这样您就不必将此repositories块添加到每个单独的模块的构建文件中。如果情况确实如此,那么这种补救办法就不会有效,所以你必须深入挖掘。

答案 1 :(得分:1)

确保Android Studio中的“全局Gradle设置”未设置为“离线工作”