由于网关错误,无法解析Android依赖项:502



12月8日,我开始在运行一个已经发布到Google Play的Android项目(使用Flutter框架创建(时遇到问题,以前编译时从未遇到过问题。

我得到的错误如下:

Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.

> Could not resolve com.google.android.gms:play-services-measurement-base:[18.0.0].
Required by:

project :app > project :firebase_analytics > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement:18.0.0

project :app > project :firebase_analytics > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement-api:18.0.0
project :app > project :firebase_analytics > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement-sdk:18.0.0
project :app > project :firebase_analytics > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement:18.0.0 > com.google.android.gms:play-services-measurement-impl:18.0.0
project :app > project :firebase_analytics > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement-api:18.0.0 > com.google.android.gms:play-services-measurement-sdk-api:18.0.0


> Failed to list versions for com.google.android.gms:play-services-measurement-base.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-measurement-base/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-measurement-base/maven-metadata.xml'.

> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-measurement-base/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

所以我开始挖掘,发现我最近的变化不是问题所在。看起来Bintray下载中心在12月1日日落(google.Bintray.com(

由于我使用的是一些Firebase软件包的旧版本,所以这个链接似乎已经关闭,现在我无法编译我的应用程序。

Flutter刮刀输出:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 2.0.3, on macOS 11.4 20F71 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.63.1)
[✓] Connected device (3 available)
• No issues found!

这是我的build.gradle:

buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
jcenter()

}
dependencies {
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.1'
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

这是我的应用程序/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) {
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
throw new GradleException("versionName not found. Define flutter.versionName in the local.properties file.")
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.reliqium.reliqium"
minSdkVersion 24
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
if (System.getenv()["CI"]) { // CI=true is exported by Codemagic
storeFile file(System.getenv()["FCI_KEYSTORE_PATH"])
storePassword System.getenv()["FCI_KEYSTORE_PASSWORD"]
keyAlias System.getenv()["FCI_KEY_ALIAS"]
keyPassword System.getenv()["FCI_KEY_PASSWORD"]
} else {
keyAlias System.getenv("RELIQIUM_ANDROID_KEYSTORE_ALIAS")
keyPassword System.getenv("RELIQIUM_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
storeFile file(System.getenv("HOME") + "/keystores/reliqiumapp.keystore")
storePassword System.getenv("RELIQIUM_ANDROID_KEYSTORE_PASSWORD")
}
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.facebook.android:facebook-core:7.0.1'
implementation 'com.facebook.android:facebook-login:7.0.1'
implementation "com.airbnb.android:lottie:3.5.0"
implementation "com.android.support.constraint:constraint-layout:2.0.4"
}

Flutter Firebase软件包的版本如下:

  • cloud_firestore:^0.16.0+1
  • firebase_analytics:^7.0.1
  • firebase_auth:^0.20.1
  • firebase_core:^0.7.0
  • firebase_crashlytics:^0.4.0+1
  • firebase_dynamic_links:^0.7.0
  • firebase_messaging:^8.0.0-dev.14
  • firebase_remote_config:^0.6.0
  • firebase_storage:^7.0.0

我知道,这些都是Firebase软件包的过时版本(由于多种原因,将它们升级到下一个版本是不可行的(

问题似乎与Firebase Analytics软件包有关。我曾试图删除它,但后来我在应用程序所需的Firebase Cloud Firestore包中遇到了类似的错误。

请有人帮我做这个。我已经尝试了很多方法,但似乎没有什么能解决这个问题,我需要编译应用程序来尽快推出新版本!

我通过将Gradle版本升级到v4.1.0 解决了这个问题

android/build.gradle:

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

android/gradle/wrapper/gradle-wrapper.properties:

...
distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip

(编辑(:你还需要更多的东西:

  1. 从build.gradle中删除jcenter((
buildscript {
...
repositories {
google()
mavenCentral() // add this
// jcenter() // remove this
}
}
...
allprojects {
repositories {
google()
mavenCentral()// ADD THIS
// jcenter() // REMOVE THIS
}
}
  1. 开关迷你已启用&在app/build.gradle中将shrinkResources设置为false:
android {
... 
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false // ADD THIS
shrinkResources false // ADD THIS
}
}
...
}

com.google.android.gms:play services度量基准:[18.0.0]的版本没有严格指定的基本问题,gradle必须找到可能的版本,但google.bintry.com已关闭-没有可用的版本列表

解决此问题的基本流程

  1. 查找版本-这[18.0.0]意味着它有版本范围渐变声明版本和范围

  2. 搜索com.google.android.gms:play services measurement base的版本,找到可以设置Maven搜索的版本。我们有版本18.0.0-18.0.3

  3. [和]符号表示只有一个版本的包含边界,因此考虑采用18.0.0 Gradle Declaring Versions and Ranges

  4. 使用最大可能版本18.0.0 限制您的可传递依赖

编辑您的项目app/build.gradle:

dependencies {
...
constraints {
implementation('com.google.android.gms:play-services-measurement-base') {
version {
strictly '18.0.0'
}
}
}
}

相关内容

最新更新