android - 尝试在我的应用程序上集成 Google 登录时出现依赖性错误

标签 android

我正在按照本指南将 Google 登录功能集成到我的应用中 https://developers.google.com/identity/sign-in/android/start-integrating

这是我的应用级别 build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.example"
        minSdkVersion 19
        targetSdkVersion 27
        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:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    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'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'

}

在添加 implementation 'com.google.android.gms:play-services-auth:15.0.1' 时,我在 implementation 'com.android.support:appcompat-v7 上出错:27.1.1'

错误是

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

我查看了库文件夹,发现有两个版本号不同的库。见下图

enter image description here

如何解决这个问题?

最佳答案

在最后添加下面到你的应用程序级gradle

    configurations.all {
    resolutionStrategy {
        eachDependency {
            DependencyResolveDetails details ->
                if (details.requested.group == 'com.android.support') {
                    if (!requested.name.startsWith("multidex")) {
                        details.useVersion "27.1.1"
                    }
                }
        }
    }
}

关于android - 尝试在我的应用程序上集成 Google 登录时出现依赖性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50735051/

相关文章:

android - 离线使用 jQuery Mobile

android - 如何在 Android Studio 中制作具有透明背景的图像资源? (带有选项添加图像 Assets )

android - Firebase 中的 FCM token 是什么?

android - 在我的 Nexus 5X And​​roid 应用程序中,相机 View 是颠倒的?

android - 如何检查是否安装了拨号器应用程序?

android - 多次发布同一个应用

java - 如何在 API 24 及更高版本的另一个应用程序中打开文件 - android

Android EditText 事件监听器

java - 如何使用 cursoradapter 实现自动完成

java - 使用 Google Maps Android API 2.0 的 Android 应用程序, map 不会移动