构建 gradle 时出错 - com.google.android.gms:play-services-basement 正在被各种其他库请求

Error in building gradle - com.google.android.gms:play-services-basement is being requested by various other libraries

我正在尝试使用 Firebase-UI 库将 Facebook 登录功能集成到我的 android 应用程序中。我正在学习本教程 - https://firebase.google.com/docs/auth/android/firebaseui?authuser=0

但是我在尝试构建时出现以下错误 gradle:

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

下面是我的应用级别build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "company.com.mygame"
        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'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.0'

    implementation 'com.facebook.android:facebook-android-sdk:4.37.0'

    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.firebaseui:firebase-ui-auth:4.2.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

我看到了以下链接 -

https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37

但是我得到这个错误 -

Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.firebaseui:firebase-ui-auth:4.2.0] C:\Users\me\.gradle\caches\transforms-1\files-1.1\firebase-ui-auth-4.2.0.aar\xxx\AndroidManifest.xml as the library might be using APIs not available in 15
    Suggestion: use a compatible library with a minSdk of at most 15,
        or increase this project's minSdk version to at least 16,
        or use tools:overrideLibrary="com.firebase.ui.auth" to force usage (may lead to runtime failures)

但问题仍未解决。我刚开始学习 android,不知道我错过了什么。

您的错误显示:uses-sdk:minSdkVersion 15 cannot be smaller than version 16 而您的 build.gradleminSdkVersion 15。尝试将其更改为 16,看看是否适合您。

学习一切顺利android。愿原力与你同在

完完全全,

阿希什

我遇到了同样的问题

只需确保您拥有所有依赖项的最新版本。我将当前版本用于 Firebase 核心和身份验证。

您可以从 here 获取最新版本。 使用当前时间点的最新版本:

在app/build.gradle :

 dependencies {
    ...
    // Add these code
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
 }

在android/build.gradle :

buildscript {
    ext {
        ...
        minSdkVersion = 16
        ...
    }
}