无法将Android Studio与Maven存储库同步

时间:2015-05-04 13:32:55

标签: java android maven android-studio gradle

我正在尝试将此库添加到我的项目中:

但Android Studio正在返回此错误:

  

错误:(8,13)无法解决:   com.github.castorflex.smoothprogressbar:库:1.1.0

     

错误:(6,13)无法解决:   com.loopj.android:android-async-http:1.4.6

     

错误:(7,13)无法解决:   com.google.apis:谷歌-API服务-分析: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工作正常,我没有做任何配置。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:3)

首先尝试在代码后添加到Project build.gradle文件中,或者只将其添加到现有的存储库

repositories {
        mavenCentral()
    }

您也可以启用"Offline mode"。检查是否启用了File -> Build,Execution,Deployment-> Maven/Gradle "Offline work",如果是,请将其停用并Sync Gradle

让我知道结果。

答案 1 :(得分:0)

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