Lunchbox
Lunchbox

Reputation: 1550

Android studio Failed to find: com.getbase:floatingactionbutton:1.3.0

I am trying to run my gradle file with an already existing android project. The only error that I have with this application is Failed to find: com.getbase:floatingactionbutton:1.3.0. Below is my gradle file. Is there something that I need to change to get it to work?

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

Please let me know if you require additional information. Thank you in advance!

Upvotes: 3

Views: 891

Answers (2)

Vinod
Vinod

Reputation: 3239

Make sure your "Global Gradle Settings" in Android Studio is NOT set for "Offline Work"

Upvotes: 1

Scott Barta
Scott Barta

Reputation: 80020

According to a search on Maven Central at http://search.maven.org/#search%7Cga%7C1%7Cfloatingactionbutton that library exists, so I think the problem may be that you haven't added a repositories statement to your build script to let it resolve dependencies; the one you've got in the buildscript block is only to resolve build system plugins, not build dependencies. I know it's confusing. Add this block at the top level:

repositories {
    mavenCentral()
}

I'm assuming also that you have a project with a flat directory structure and a single build.gradle file; when Android Studio creates projects via the wizard it uses a nested directory structure with multiple build.gradle files, and it normally adds boilerplate at the top-level build file so that you don't have to add this repositories block to each individual module's build file. If that's the case and that's in place, then this remedy won't work, so you'll have to dig deeper.

Upvotes: 1

Related Questions