Firebase云消息传递gradle设置

时间:2019-03-15 07:00:13

标签: android firebase android-gradle firebase-cloud-messaging

我正在尝试在我的应用程序中添加Firebase云消息传递,但问题恰好存在于我的gradle依赖项中

这就是我在依赖项中添加的内容:

implementation 'com.google.firebase:firebase-messaging:17.3.3'

但是它不起作用最终会显示错误。

我的项目gradle:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'

        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

我的应用gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.my.package"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 12
        versionName "12.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }
}

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 'com.android.support:support-v4:28.0.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'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.0.5'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'de.hdodenhof:circleimageview:2.0.0'
    implementation 'com.sothree.slidinguppanel:library:3.4.0'
    implementation 'com.cocosw:bottomsheet:1.+@aar'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.github.ybq:AndroidSpinKit:v1.0.0'
    implementation 'com.google.android.gms:play-services-ads:17.1.2'
}
apply plugin: 'com.google.gms.google-services'

错误日志

logcat 任何解决方案??我还尝试将所有依赖项更新到他们的新版本,但是也没有用。

2 个答案:

答案 0 :(得分:1)

查看Firebase Android Release Notes,了解可用于 Firebase 功能不同内核的最新版本。

implementation 'com.google.firebase:firebase-messaging:17.4.0' 

尝试将其更新为可用的最新版本。

答案 1 :(得分:0)

尝试更改以前使用过的gradle版本,几天前我也遇到了同样的问题

classpath 'com.android.tools.build:gradle:3.2.1'