NSouth
NSouth

Reputation: 5276

Failed to resolve com.melnykov:floatingactionbutton:1.3.0 in gradle

I apologize if I am missing something obvious, but I recently converted my project from Eclipse to Android Studio (and Gradle) and am trying to add support for Floating Action Buttons using Melnykov's library, but Gradle cannot resolve it. I thought it was a simple matter of adding compile 'com.melnykov:floatingactionbutton:1.3.0' to my app's build.gradle file. Am I missing something or is the source not available to download or what? Thanks ahead of time.

My app's build.gradle file:

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

And the error I get is

Error:(6, 13) Failed to resolve: com.makovkastar:floatingactionbutton:1.3.0

Upvotes: 0

Views: 1179

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364451

You have to add the repository from which gradle should download the aar.

repositories {
    jcenter()
}

Without this part, gradle doesn't know where to find the dependencies.

The other libraries don't need the repo because they are local jars (they can be found in the lib folder):

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

or a local maven (provided with the sdk manager)

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

Upvotes: 1

NSouth
NSouth

Reputation: 5276

The error seems to have been resolved after adding the jcenter repository like this. I don't fully understand it, but everything compiles now.

...
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()
}
...

Upvotes: 0

Related Questions