Android Studio Gradle文件中的版本错误

时间:2018-09-21 03:22:54

标签: android android-studio

这是我的gradle文件。每当我尝试编译甚至进行干净的构建时,我都会遇到一条错误消息:

”“请通过更新google-services插件的版本(有关最新版本的信息可在https://bintray.com/android/android-tools/com.google.gms.google-services/中进行修复)或将com.google.android.gms的版本更新为16.0来解决版本冲突。 3。 “

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "studio.in.prakharshuka.atlastodo"
        minSdkVersion 22
        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'
        }
    }
}
//com.google.android.gms to 11.6.0.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-database:16.0.2'
    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'

请告诉我我在做什么错。我将Firebase身份验证和数据库连接到我的应用程序。

2 个答案:

答案 0 :(得分:0)

这不应该引起错误,应该只是警告。但是尽管如此,请尝试:

1)将两个Firebase依赖关系都保持在16.0.2版。

2)添加implementation 'com.google.firebase:firebase-core:16.0.2'依赖性。

答案 1 :(得分:0)

尝试一下:

第一步

  • 如果您使用的是google-services依赖项,则所有版本均如下所示:

    apply plugin: 'com.android.application'
    
     android {
    compileSdkVersion 28
    defaultConfig {
    applicationId "studio.in.prakharshuka.atlastodo"
    minSdkVersion 22
    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'
    }
      }
       }
         //com.google.android.gms to 11.6.0.
    
      dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
      implementation 'com.android.support.constraint:constraint-layout:1.1.3'
      implementation 'com.google.firebase:firebase-messaging:11.8.0'
      implementation 'com.google.firebase:firebase-config:11.8.0'
      implementation 'com.google.firebase:firebase-auth:16.0.1'
      implementation 'com.google.firebase:firebase-database:16.0.1'
      implementation 'com.google.firebase:firebase-storage:16.0.1'
      implementation 'com.google.firebase:firebase-core:16.0.3'
      implementation 'com.google.firebase:firebase-iid:17.0.1'
      implementation 'com.google.firebase:firebase-messaging:17.3.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'
      }
    
    
     apply plugin: 'com.google.gms.google-services'
    

第二步

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:3.2.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}


  allprojects {
  repositories {
    jcenter()
    google()
    maven { url "https://jitpack.io" }
}
 }


task clean(type: Delete) {
delete rootProject.buildDir
 }