关于android:Gradle项目同步失败

Gradle Project Sync Failing

我的项目同步失败,出现以下错误-

无法解决":app @ debug / compileClasspath"的依赖项:无法下载exoplayer-core.aar(com.google.android.exoplayer:exoplayer-core:r2.4.2)

无法解决对':app @ debugAndroidTest / compileClasspath'的依赖关系:无法下载exoplayer-core.aar(com.google.android.exoplayer:exoplayer-core:r2.4.2)

无法解决对':app @ debugUnitTest / compileClasspath'的依赖关系:无法下载exoplayer-core.aar(com.google.android.exoplayer:exoplayer-core:r2.4.2)

无法解决对':app @ release / compileClasspath'的依赖关系:无法下载exoplayer-core.aar(com.google.android.exoplayer:exoplayer-core:r2.4.2)

无法解析':app @ releaseUnitTest / compileClasspath'的依赖项:无法下载exoplayer-core.aar(com.google.android.exoplayer:exoplayer-core:r2.4.2)

我的Project build.grade看起来像这样-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven {
            url"https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的App gradle文件看起来像-

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId"com.android.application"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName"1.0"
        testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.android.gms:play-services-ads:17.1.2'
    implementation 'com.google.android.gms:play-services-analytics:16.0.6'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.facebook.android:audience-network-sdk:5.1.0'
}

在这方面的任何帮助,将不胜感激!!!
我该如何解决?

我尝试了"使缓存无效/重新启动"选项,并且还尝试重建项目,但没有帮助。


自今天以来,Exoplayer-core和Exoplayer-dash似乎已损坏
https://github.com/google/ExoPlayer/issues/5225


So for sure if you didn't include exoplayer library in your
build.gradle, your project won't synch.

更新:
好的,很抱歉,现在我遇到了大家都在使用com.facebook.android:audience-network-sdk的问题,这就是为什么,为什么在您的build.gradle文件中没有设置exoplayer依赖关系。

如果您未明确指定exoplayer-coreexoplayer-dash,请使用依赖于exoplayercom.facebook.android:audience-network-sdk,gradle尝试下载文档所需的依赖项。

因此,正如@laylakn所指出的(为此提出支持),在bintray和jcenter之间的存储库镜像之间存在问题。

因此,特别针对您的问题,因为您已经告诉我您尝试添加库和同步操作没有成功,这是因为要查找的exoplayer版本(r2.4.2)在spring plugin repository中。

spring plugin repo

因此,您应该将其添加为您的Maven仓库(由于之前所述的仓库镜像错误):

1
2
3
maven {
        url"https://repo.spring.io/plugins-release/"
      }

或如在主要GitHub存储库上的解释,仅直接指向bintray。

1
2
3
maven {
            url 'https://google.bintray.com/exoplayer/'
        }

并且您应该添加两个库来同步您的项目:

1
2
implementation 'com.google.android.exoplayer:exoplayer:r2.4.2'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.4'

enter image description here

因此,现在我很高兴向您提出镜像问题已解决,并且您现在可以同步,而无需对build.gradle文件进行任何更改。

我已经离开并更新了答案,以更好地解释这种情况。

其他一些著名的回购协议也要采取预防措施:[-:

enter image description here


通过此Gradle配置,它可以正常工作:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
android {
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 27
defaultConfig {
    ...
    targetSdkVersion 27
        ...
  }
}




ext {
    exoplayer_version = '2.9+'
}

dependencies {
    ...

//exoplayer

implementation ('com.google.android.exoplayer:exoplayer-core:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-dash:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-hls:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-smoothstreaming:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer-ui:' + exoplayer_version)
implementation ('com.google.android.exoplayer:exoplayer:' + exoplayer_version)