Gradle failed to resolve library in Android Studio

半城伤御伤魂 提交于 2019-11-26 16:39:36
Sibo

To be able to use a lib project you need to include it in your application's settings.gradle add:

include '..:ExpandableButtonMenu:library'

and then in your build.gradle add:

compile project(':..:ExpandableButtonMenu:library') 

place ExpandableButtonMenu project along side your own (same folder)

see this How to build an android library with Android Studio and gradle? for more details.

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 !

AnEnthusiast

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

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" }
    }
}

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

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

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

Vivek Nayak

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
Roman Black
repositories {
    mavenCentral()
}

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

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

}

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!