从eclipse中迁移项目到android studio中,编译出现以下错误


报错如下错误:

Error:Failed to resolve: com.tencent.tinker:tinker-android-lib:1.6.2
Open FileShow      in Project Structure dialog


解决方法:


//加这个进行加载仓库jar包,问题的主要解决方法repositories {    mavenCentral()    mavenLocal()    jcenter()}buildscript {    repositories {        mavenCentral()        mavenLocal()        jcenter()    }    dependencies {        classpath 'com.android.tools.build:gradle:2.1.0'        //  tinker 热修复        classpath "com.tencent.tinker:tinker-patch-gradle-plugin:${TINKER_VERSION}"    }}apply plugin: 'android'//  tinker热修复apply plugin: 'com.tencent.tinker.patch'dependencies {    compile fileTree(dir: 'libs', include: '*.jar')    compile("com.tencent.tinker:tinker-android-lib:${TINKER_VERSION}")  { changing = true }    compile("com.tencent.tinker:tinker-android-anno:${TINKER_VERSION}")  { changing = true }    compile "com.android.support:multidex:1.0.1"}

参考来自以下文章:

http://stackoverflow.com/questions/29118606/gradle-in-android-studio-failed-to-resolve-third-party-libraries

Gradle failed to resolve library in Android Studio

up vote 13 down vote favorite 3

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')    }
android  gradle  libraries
share improve this question edited  Jan 15 at 10:16 Liuting 611 8 28 asked  Feb 13 '15 at 6:03 Bekti 128 1 4 13
 
1  
where have you inserted the lib and what is the log? –  therealprashant  Feb 13 '15 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'" –  Bekti  Feb 13 '15 at 6:10
 
Show us your build.gradle. –  Jared Burrows  Feb 13 '15 at 6:32
 
Not sure but try this File -> Invalidate caches/restart-> choose Invalidate caches/restart. –  Yuva Raj  Feb 13 '15 at 6:34
1  
@yuya raj , i have tried but not work –  Bekti  Feb 13 '15 at 7:12 
show  1 more comment

6 Answers

active oldest votes
up vote 3 down vote accepted

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.

share improve this answer edited  Feb 13 '15 at 9:25 answered  Feb 13 '15 at 6:31 YourJavaMinion 364 2 15
 
 
what to do after select lib ? –  Bekti  Feb 13 '15 at 7:11
 
sync project with gradle files. –  YourJavaMinion  Feb 13 '15 at 7:58
 
i've tried, and stil not work –  Bekti  Feb 13 '15 at 8:01 
 
see edited answer –  YourJavaMinion  Feb 13 '15 at 9:29
 
thanks...you are the best ... –  Bekti  Feb 13 '15 at 9:37
add a comment
up vote 47 down vote

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 !

share improve this answer answered  Feb 25 '15 at 5:23 Nhat Pham 471 2 2
 
 
Thanks this thing worked for my .thanks alot –  Hardy  Apr 10 '15 at 6:44
 
This worked for me as well I don't know why it got checked -_- –  Dr. aNdRO  Apr 29 '15 at 5:14
 
Thanks a lot for this! –  wtk  May 14 '15 at 12:40
3  
Thanks! If only gradle said "cannot resolve but you are in offline mode if you hadn't realised". –  David Amey May 19 '15 at 14:33
1  
Exactly. Android Studio has miles to go –  rockydgeekgod  Jun 9 '15 at 6:12
add a comment
up vote 16 down vote

I had the same problem, first thing came on mind was about repositories. So i checked build.gradle file for the whole project and added below lines, synchronized the gradle with project and problem solved! Hope will help someone else.

allprojects {    repositories {        jcenter()    }}
share improve this answer answered  Sep 30 '15 at 18:57 AnEnthusiast 518 4 13
 
 
this actually is the prescribed solution to most occurrences of the said problem –  frederick nyawaya  Oct 1 '15 at 12:42
add a comment
up vote 2 down vote

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.

share improve this answer answered  Feb 24 '15 at 4:36 CoderRed 21 1
  add a comment
up vote 1 down vote

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

share improve this answer answered  Feb 13 '15 at 7:36 hidro 5,735 4 25 30
 
 
i have tried like that but still error –  Bekti  Feb 13 '15 at 7:43
add a comment
up vote 0 down vote

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
share improve this answer edited  Dec 17 '15 at 9:31 Mohit 2,360 8 15 25 answered  Dec 17 '15 at 9:08 Vivek Nayak 1 3

更多相关文章

  1. Android:从Eclipse到Android(安卓)Studio迁移工程
  2. Android(安卓)Tips
  3. Android(安卓)热修复案例
  4. Android热修复原理普及
  5. Android(安卓)简单热修复(上)——Java类加载器
  6. Ubuntu 13.04 编译环境配置及android 2.3 源代码编译时出现了以
  7. Android(安卓)运行出错
  8. android之android.os.NetworkOnMainThreadException错误
  9. Android(安卓)开发中遇到的 bug(3)

随机推荐

  1. android TextView 容纳不下内容,让字向左
  2. 关于android多点触控
  3. android 主activity 设置
  4. Android(安卓)使用RecyclerView的方法
  5. 抽离Android原生控件的方法
  6. Android TV webview禁止自动获取焦点 遥
  7. android studio打开react-native的androi
  8. Android(安卓)ViewPager与子控件点击事件
  9. Android学习札记15:对Android中View绘制流
  10. Android的Activity and Task Design