48

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') } 
6
  • 1
    where have you inserted the lib and what is the log? Commented Feb 13, 2015 at 6:07
  • in gradle , i type compile 'com.lemonlab:expandable-button-menu:1.0.0' , after that i sync and display error "Failed to resolve:com.lemonlab:expandable-button-menu:1.0.0'" Commented Feb 13, 2015 at 6:10
  • Show us your build.gradle. Commented Feb 13, 2015 at 6:32
  • Not sure but try this File -> Invalidate caches/restart-> choose Invalidate caches/restart. Commented Feb 13, 2015 at 6:34
  • 1
    @yuya raj , i have tried but not work Commented Feb 13, 2015 at 7:12

14 Answers 14

59

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 !

Sign up to request clarification or add additional context in comments.

3 Comments

This worked for me as well I don't know why it got checked -_-
Thanks! If only gradle said "cannot resolve but you are in offline mode if you hadn't realised".
Exactly. Android Studio has miles to go
56

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

2 Comments

this actually is the prescribed solution to most occurrences of the said problem
Could you elaborate on this? Why allprojects ?
25

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

1 Comment

This one worked for me...
12

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.

2 Comments

what to do after select lib ?
sync project with gradle files.
6

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

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

Comments

5

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

Comments

5

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.

Comments

3

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

2 Comments

After an hour of trying everything I could think of, a simple restart solved the problem. Sometimes I hate Android Studio....
@Apfelsaft Restart the PC? or AS itself? What is your OS?
2
repositories { mavenCentral() } 

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

Comments

1

I have been facing this error and fixed by adding this in my settings.gradle

Groovy

maven { url 'https://jitpack.io' } 

under dependencyResolutionManagement

Kotlin Scripts

maven { setUrl( "https://jitpack.io") } 

Screenshot

Comments

0

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

Comments

0

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

Comments

0

If adding repositories didn't work, check that your settings.gradle contains:

 repositoriesMode.set(RepositoriesMode.PREFER_PROJECT) 

Comments

0

My reason for this type of error was requesting a non-existent release. Verify your names and version numbers. As noted by lamat8: Any error in your build files can cause this.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.