2015-05-04 15 views
0

我想这个库添加到我的项目:无法同步的Android Studio和Maven仓库

但是Android工作室返回此错误:

Error:(8, 13) Failed to resolve: com.github.castorflex.smoothprogressbar:library:1.1.0

Error:(6, 13) Failed to resolve: com.loopj.android:android-async-http:1.4.6

Error:(7, 13) Failed to resolve: com.google.apis:google-api-services-analytics:v3-rev115-1.20.0

这是我build.grade文件:

apply plugin: 'com.android.application' 


dependencies { 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile project(':librarySmartHotel') 
    compile 'com.loopj.android:android-async-http:1.4.6' 
    compile 'com.google.apis:google-api-services-analytics:v3-rev115-1.20.0' 
    compile 'com.github.castorflex.smoothprogressbar:library:1.1.0' 
    compile 'com.google.android.gms:play-services:6.5.87' 
} 

android { 
    compileSdkVersion 19 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     multiDexEnabled true 
    } 

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

我一定要配置什么?例如com.google.android.gms:play-services:6.5.87正在运行完美,我还没有做任何配置。

任何帮助将不胜感激。

回答

4

首先尝试添加到您的项目build.gradle文件下面的代码,或只是将其添加到资料库存在

repositories { 
     mavenCentral() 
    } 

您还可以启用"Offline mode"。检查是否启用File -> Build,Execution,Deployment-> Maven/Gradle "Offline work",如果是这样,只是禁用它和Sync Gradle

并让我知道结果。

+0

我刚刚添加了代码,一切都开始正常工作,谢谢! –

+0

不客气 – CROSP

+0

@CROSP真棒男人你让我的一天,“离线模式”是罪魁祸首 –

0

Gradle构建您提到的完美编译与我的。我建议你清理你的项目并重新启动android studio并再次尝试。如果问题仍然存在,请告诉我们。