无法在gradle中解析com.melnykov:floatingactionbutton:1.3.0

时间:2015-04-25 01:08:05

标签: android android-studio gradle android-gradle build.gradle

如果我遗漏了一些明显的东西,我很抱歉,但我最近将我的项目从Eclipse转换为Android Studio(和Gradle),并尝试使用Melnykov's library添加对浮动动作按钮的支持,但Gradle无法解决它。我认为将compile 'com.melnykov:floatingactionbutton:1.3.0'添加到我的应用的build.gradle文件是一件简单的事情。我是否遗漏了某些内容,或者是无法下载的来源或什么?提前谢谢。

我的应用build.gradle个文件:

apply plugin: 'android'

dependencies {
    compile 'com.android.support:support-v4:22.1.0'
    compile files('libs/opencsv-3.1.jar')
    compile 'com.android.support:appcompat-v7:22.1.0'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
}

android {
    compileSdkVersion 22
    buildToolsVersion "22"

    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')
    }
}

我得到的错误是

  

错误:(6,13)无法解决:   com.makovkastar:floatingactionbutton:1.3.0

2 个答案:

答案 0 :(得分:1)

您必须添加gradle应从中下载aar的存储库

repositories {
    jcenter()
}

没有此部分,gradle不知道在哪里可以找到依赖项。

其他库不需要repo,因为它们是本地jar(可以在lib文件夹中找到):

compile files('libs/opencsv-3.1.jar')

或当地专家(随sdk经理提供)

  compile 'com.android.support:support-v4:22.1.0'
  compile 'com.android.support:appcompat-v7:22.1.0'

答案 1 :(得分:0)

在添加像这样的jcenter存储库之后,似乎已经解决了该错误。我不完全理解它,但现在一切都在编译。

...
dependencies {
    compile 'com.android.support:support-v4:22.1.0'
    compile files('libs/opencsv-3.1.jar')
    compile 'com.android.support:appcompat-v7:22.1.0'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
}

repositories {
    jcenter()
}
...