无法解析 com.google.android.gms:play-services-measurement-base:[18.0.0]

Posted

技术标签:

【中文标题】无法解析 com.google.android.gms:play-services-measurement-base:[18.0.0]【英文标题】:Could not resolve com.google.android.gms:play-services-measurement-base:[18.0.0] 【发布时间】:2022-01-14 01:15:42 【问题描述】:

我对 Flutter 比较陌生,该项目在 2 天前开始工作。 当我今天尝试运行它时,我遇到了这个错误。 这是我面临的错误。

FAILURE: Build failed with an exception.

* What went wrong:
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 > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement:18.0.0
         project :app > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement-api:18.0.0
         project :app > com.google.firebase:firebase-analytics:18.0.0 > com.google.android.gms:play-services-measurement-sdk:18.0.0
         project :app > 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 > 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

这是我的 app\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 plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android 
    compileSdkVersion 29

    sourceSets 
        main.java.srcDirs += 'src/main/kotlin'
    

    lintOptions 
        disable 'InvalidPackage'
    

    defaultConfig 
        applicationId "com.project.project"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    

    buildTypes 
        release 
            signingConfig signingConfigs.debug
        
    


flutter 
    source '../..'


dependencies 
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:26.1.1')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.android.support:multidex:1.0.3'

我尝试更新 firebase-bom 和 google-services,但仍然面临同样的问题。 任何帮助将不胜感激!

【问题讨论】:

你把classpath 'com.google.gms:google-services:4.3.8'放到android/build.gradle了吗? 我做到了。我使用的是classpath 'com.google.gms:google-services:4.3.4',但即使更新后,它也不起作用。 面临完全相同的问题。 任何解决方法? @DhanrajVerma 试试 MrZero 的答案。它对我有用。如果它仍然对您不起作用,那么临时的解决方法是在构建应用程序时关闭您的 WiFi。之后您可以将其重新打开。 【参考方案1】:

在 gradle-wrapper.properties 中将 distributionUrl 更改为

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

【讨论】:

对于未来的读者,请参阅here 了解有关这是什么以及如何获取当前版本的更多信息 我也有同样的问题。我正在使用依赖项 classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.google.gms:google-services:4.3.5' 我有类似的问题。我正在使用依赖项 classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.google.gms:google-services:4.3.5' DistributionUrl 应该使用什么?【参考方案2】:

删除这个,它是firebase插件添加的

implementation platform('com.google.firebase:firebase-bom:26.1.1')

implementation 'com.google.firebase:firebase-analytics'

并且 将 gradle 版本设置为 4.1.0

以及分发网址 distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

【讨论】:

谢谢,它的工作就像一个魅力。你让我开心!!

以上是关于无法解析 com.google.android.gms:play-services-measurement-base:[18.0.0]的主要内容,如果未能解决你的问题,请参考以下文章

谷歌地图修订版。 30 日食用法:google_play_services_version

nslookup 报告“无法解析 '(null)':名称无法解析”,尽管它成功解析了 DNS 名称

Constraint 无法解析为类型

Ubuntu 无法解析域名

无法解析的外部符号 C++

C++无法解析的外部命令和外部符号