所有gms / firebase库必须使用完全相同的版本规范Android Studio

时间:2018-05-15 04:13:41

标签: android firebase android-gradle google-play-services

我知道很多时候都会问过这个问题,但我无法弄清楚这一点。让我解释2月5日firebase已经宣布Firebase Android SDK现在拥有独立的版本号。点击此处:Firebase Android Release Notes

所以我根据项目中的文档更改了所有firebase库的版本号。之后,Android Studio开始在classpath 'com.google.gms:google-services:3.2.1'

上显示警告消息

但它编译并成功生成构建没有错误发生和应用程序运行完美。有一天我发现Firebase崩溃日志中有关于我的生产应用中google-play-service的问题。由于变化或其他原因,我不知道这种情况。首先,我想在gradle文件中删除此错误消息。 校验: enter image description here

enter image description here

Google服务插件: buildscript { repositories { jcenter() mavenCentral() maven { url 'https://maven.google.com/' name 'Google' } maven { url 'https://maven.fabric.io/public' } google() } dependencies { classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.google.gms:google-services:3.2.1' classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' classpath 'io.fabric.tools:gradle:1.25.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() maven { url "https://jitpack.io" } maven { url 'https://maven.google.com/' name 'Google' } google() } } task clean(type: Delete) { delete rootProject.buildDir } 我这里有三个模块是所有模块和项目的gradle文件。

Project gradle:

    apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.xyz.xyz"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 97
        versionName "2.3.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resConfigs "en", "hi"
    }
    dexOptions {
        javaMaxHeapSize "4072M"
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    aaptOptions {
        cruncherEnabled = false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

greendao {
    schemaVersion 62
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation('com.facebook.android:facebook-android-sdk:[4,5)') {
        exclude group: "com.android.support"
    }
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
    implementation project(path: ':library')
    implementation project(path: ':showcase')
    implementation project(path: ':cropper')
    /* compile 'org.projectlombok:lombok:1.16.16'*/
    /*annotationProcessor 'org.projectlombok:lombok:1.16.16'*/
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.github.jd-alexander:LikeButton:0.2.1'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.firebase:firebase-auth:15.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-config:15.0.2'
    implementation 'com.google.firebase:firebase-crash:15.0.2'
    implementation 'com.google.firebase:firebase-invites:15.0.1'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.hbb20:ccp:1.8'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
    implementation 'org.greenrobot:greendao:3.2.2'
    implementation 'com.clevertap.android:clevertap-android-sdk:3.1.4'
    testImplementation 'junit:junit:4.12'
    implementation 'android.arch.lifecycle:runtime:1.1.1'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.caverock:androidsvg:1.2.1'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
}

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

app gradle:

 apply plugin: 'com.android.library'

android {

    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName '2.4.7'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation "com.android.support:exifinterface:27.1.1"
}

Cropper gradle

    apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    testImplementation 'junit:junit:4.12'
}

图书馆gradle:

    buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

dependencies {
    repositories {
        mavenCentral()
    }
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

SHOWcase gradle:

{{1}}

4 个答案:

答案 0 :(得分:1)

解决方案是:

将您的依赖项更改为12.0.1并将gradle插件降级到版本3.2.1。

在多模块应用中使用google-services 3.3有一个known issue。这意味着在修复错误的新版本发布之前,将google-services降级到3.2.1可能是唯一的选择。

答案 1 :(得分:0)

此更改引入了Google Services 3.3。因此,将类路径升级为:

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

由于您使用的是较旧版本的Google服务,因此它仍然会验证所有版本必须相同的旧逻辑。

另请参阅Doug关于此更改的博文:https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

答案 2 :(得分:0)

您使用的是哪个版本的Android Studio?这个lint错误来自Google Play服务和Firebase库之前可能有不同的版本。 https://developer.android.com/studio/releases/,Android Studio的最新稳定(3.1+)版本应该免除所有较新的Google Play服务和Firebase库的检查(仍会检查15.0.0以下的版本)

博客帖子有更多详情:https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

这与使用的google-services插件版本无关。

答案 3 :(得分:0)

syn new all library firebase
implementation 'com.google.firebase:firebase-analytics:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-storage:17.0.0'