Android Studio 错误库 com.google.android.gms:play-services-measurement-base

Android Studio Error The library com.google.android.gms:play-services-measurement-base

如何做到这一点我是 Android Studio 的新手。

The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

据报道here:

You will need to update the version of the latter dependency to 15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]], but resolves to 15.0.2...

然后将您的 google 播放服务插件更新为 3.3.0

classpath 'com.google.gms:google-services:3.3.0'

并将依赖项更新为 15.0.2.

与我一起解决此问题 - 如果您选择 Firestore 数据库,请执行以下操作: 首先,我们将在 Gradle 中添加更新的这些内容:

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
    }
}

allprojects {
    // ...
    repositories {
        // ...
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
    }
}

本次更新后:

apply plugin: 'com.android.application'

android {
  // ...
}

dependencies {
  // ...
  implementation 'com.google.firebase:firebase-core:16.0.0'

  // Getting a "Could not find" error? Make sure you have
  // added the Google maven respository to your root build.gradle
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

然后 Rebuild 或 Sunc Now ,问题将得到解决。

如果您正在使用实时数据库,那么请执行以下操作:-

设置依赖关系:

implementation 'com.google.firebase:firebase-database:15.0.0'

并删除上面的 FireStore 依赖项。

这一定会解决您的问题...如果您喜欢,请投票给我

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
    }
}

这对我有用。通过添加最新版本,即 4.0.1