【问题标题】:Unable to sync Android Studio with Maven repository无法将 Android Studio 与 Maven 存储库同步
【发布时间】:2015-05-04 13:32:55
【问题描述】:

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

但 Android Studio 正在返回此错误:

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

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

错误:(7, 13) 无法解决: 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 工作完美,我没有做任何配置。

任何帮助将不胜感激。

【问题讨论】:

    标签: java android maven android-studio gradle


    【解决方案1】:

    首先尝试将代码添加到您的项目build.gradle 文件中,或者将其添加到现有存储库中

    repositories {
            mavenCentral()
        }
    

    您也可能启用了"Offline mode"。检查File -&gt; Build,Execution,Deployment-&gt; Maven/Gradle "Offline work" 是否启用,如果启用则禁用它并Sync Gradle

    然后告诉我结果。

    【讨论】:

    • 我刚刚添加了代码,一切都开始完美运行,谢谢!!
    • @CROSP 很棒的人,你让我开心,“离线模式”是罪魁祸首
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-05
      • 2011-11-12
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多