【问题标题】:Gradle fails to resolve dependencies in Android Studio. That Is My ErrorGradle 无法解析 Android Studio 中的依赖项。那是我的错误
【发布时间】:2016-09-28 21:25:13
【问题描述】:

当我向我的 android studio 项目添加一些依赖项时出现此错误........我做错了什么?

请参阅下面的代码。提前致谢。

repositories {
        mavenCentral()
        flatDir {
            dirs 'libs'
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:support-v4:23.1.1'
        compile 'com.google.android.gms:play-services:8.3.0'
        compile 'org.json:json:20141113'
        // This library handles authentication and authorization
        compile 'com.spotify.sdk:spotify-auth-beta22-noconnect-2.20b@aar'
        // This library handles music playback
        compile 'com.spotify.sdk:spotify-player-beta22-noconnect-2.20b@aar'
        // All other dependencies for your app should also be here:
        compile 'com.android.support:appcompat-v7:23.1.1'

    }

【问题讨论】:

  • post 错误也与 post 一起,来自 post get this error,这将检查 logcat
  • @PavneetSingh 我不明白您的评论。请问您是什么意思?
  • 发布您的日志猫,并分享您的 build.gradle(模块项目)
  • 好的,谢谢...我会的

标签: java android android-studio dependencies


【解决方案1】:

从您的应用级别 build.gradle 文件中删除以下代码并将其放入您的项目级别 build.gradle

repositories {
        mavenCentral()
        flatDir {
            dirs 'libs'
        }
    }

【讨论】:

    【解决方案2】:

    请试试这个...

    1)。 compile fileTree(include: ['*.jar'] , dir: 'libs')

    2)。缺少 testCompiler testCompile 'junit:junit:4.12'

    在编译文件树下面添加这个 testCompiler,如下所示-

    compile fileTree(include: ['*.jar'] , dir: 'libs')
        testCompile 'junit:junit:4.12'
    

    并删除

    repositories {
            mavenCentral()
            flatDir {
                dirs 'libs'
            }
        }
    

    并将其粘贴到 Gradle 项目中

    【讨论】:

    • 感谢@Shivam,我仍然面临错误。请参阅下面的错误。
    • 错误:无法解析:com.spotify.sdk:spotify-player-beta22-noconnect-2.20b:错误:无法解析:com.spotify.sdk:spotify-auth-beta22-noconnect -2.20b:
    • 这显示了编译依赖项的问题,即编译 'com.spotify.sdk:spotify-player-beta22-noconnect-2.20b@aar' 并编译 'com.spotify.sdk:spotify- auth-beta22-noconnect-2.20b@aar' 检查这两个可能是错误的
    猜你喜欢
    • 2013-12-12
    • 1970-01-01
    • 2015-12-19
    • 1970-01-01
    • 2019-03-31
    • 2019-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多