[android] Gradle failed to resolve library in Android Studio

I want to include a library in Android Studio , but it displays error like below :

"Failed to resolve:com.lemonlab:expandable-button-menu:1.0.0"

How to fix this problem?

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 21
        buildToolsVersion '21.1.2'

        defaultConfig {
            applicationId "ayowes.com.newecampus"
            minSdkVersion 15
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-ptimize.txt'), 'proguard-rules.txt'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:21.0.3'
        compile 'com.google.android.gms:play-services:6.5.87'
        compile 'com.lemonlab:expandable-button-menu:1.0.0'
        compile files('libs/pinchzoom.jar')
    }

This question is related to android gradle libraries

The answer is


Solved by using "http://jcenter.bintray.com/" instead of "https://jcenter.bintray.com/".

repositories {
    jcenter( { url "http://jcenter.bintray.com/" } )
}

repositories {
    mavenCentral()
}

I added this in build.gradle, and it worked.


I had the same problem, the first thing that came to mind was repositories. So I checked the build.gradle file for the whole project and added the following code, then synchronized the gradle with project and problem was solved!

allprojects {
    repositories {
        jcenter()
    }
}

Check to see if your gradle is offline. Preferences-ProjectSettings-Gradle. If you're trying to add a library while offline, you'll see that error. Also, try Build-Clean, it may provide you with more detail.


Well, it's co.lemonlabs, you have a typo in your build.gradle:

compile 'co.lemonlabs:expandable-button-menu:1.0.0'

Source: https://github.com/lemonlabs/ExpandableButtonMenu#including-in-your-project


i had the same problem, i added the following lines in build.gradle

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }

        maven {
            url 'http://dl.bintray.com/dev-fingerlinks/maven'
        }
        mavenCentral()
    }
}

Try this

  1. Clean project
  2. Invalidate cache and restart studio
  3. Check android SDK path is proper
  4. Check is there any error in any of your resource file

Some time you may just need to add maven { url "https://jitpack.io" } in your allprojects block in project level build.gradle file.

Example:

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

You go File->Settings->Gradle Look at the "Offline work" inbox, if it's checked u uncheck and try to sync again I have the same problem and i try this , the problem resolved. Good luck !


For me follwing steps helped.

It seems to be bug of Android Studio 3.4/3.5 and it was "fixed" by disabling:

File ? Settings ? Experimental ? Gradle ? Only sync the active variant


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to libraries

Gradle failed to resolve library in Android Studio Add external libraries to CMakeList.txt c++ The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files fatal error LNK1104: cannot open file 'kernel32.lib' Node.js Logging The project was not built since its build path is incomplete libstdc++-6.dll not found How to add local jar files to a Maven project? How to add additional libraries to Visual Studio project? Java out.println() how is this possible?