java - 无法获取 'https://google.bintray.com/.../maven-metadata.xml' 。从服务器 : Forbidden 收到状态码 403

标签 java android flutter maven

当我尝试构建我的 flutter 应用程序时,我面临的问题是:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'. Could not resolve com.google.android.gms:play-services-location:16.+. Required by: project :app > project :location > Failed to list versions for com.google.android.gms:play-services-location. > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml. > Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. > Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 403 from server: Forbidden



我已经尝试了一切,但没有任何效果:
1-我有稳定的互联网连接
2-我尝试更新或降级 com.android.tools.build:gradle 版本
3-我试过清理缓存
4-我尝试删除所有 firebase 库
5-我用 mavenCentral() 替换了 JCentre()
有我的 android -> build.gradle 文件:
buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
这是我的 android build.gradle 文件:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "io.bujupah.hestia"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    testImplementation'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:2.17.0'
    implementation 'com.android.support:multidex:1.0.3'
}
最后是我 flutter 的医生结果:

[√] Flutter (Channel unknown, 2.0.0, on Microsoft Windows [version 10.0.19042.1052], locale fr-TN) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.1) [√] Chrome - develop for the web [√] Android Studio (version 4.0) [√] VS Code (version 1.57.1) [√] Connected device (3 available)

• No issues found!

最佳答案

在尝试了我在 Google 上找到的所有内容之后。我花了将近3天的时间。我终于找到了一个解决方法:
将您的 gradle 升级到最新版本。在 android/build.gradle文件:
我编辑了classpath 'com.android.tools.build:gradle:3.6.3'classpath 'com.android.tools.build:gradle:4.2.0'
android/gradle/wrapper/gradle-wrapper.properties文件:
我编辑了distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zipdistributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip我的项目又开始工作了。

关于java - 无法获取 'https://google.bintray.com/.../maven-metadata.xml' 。从服务器 : Forbidden 收到状态码 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68255521/

相关文章:

Java:ExecutorService线程与CountDownLatch同步导致死锁?

java - Spring:让 ServeltDispatcher 上下文等待直到另一个上下文完成加载

android - 在 fragment 中使用 ZXing

Flutter:如何更改幻灯片上的选项卡图标颜色,而不仅仅是点击?

java - 如何从 Controller 传递多个模型对象以及如何将所有作为命令对象传递到表单 :form in spring mvc?

java - 如何在java中将不同货币的货币表示形式转换为十进制值

android - 检查用户是否一直停留在同一个位置

java - Android java.lang.ClassCastException : android. widget.LinearLayout$LayoutParams 无法转换为 android.widget.AbsListView$LayoutParams

json - 与颜色相关的 flutter 图像

flutter - 将推送通知从 firebase_messaging 6 迁移到 firebase_messaging 10+