首页 > 解决方案 > 应用消息传递中的 Firebase(实现 'com.google.firebase:firebase-inappmessaging-display:19.1.5')与 Android 中的 gRPC 之间的冲突

问题描述

我打算在使用 gRPC 服务器的 Android 应用程序中实现 Firebase 应用内消息传递功能。但是,当我为 Firebase 应用内消息传递(implementation 'com.google.firebase:firebase-inappmessaging-display:19.1.5)添加依赖项时,我遇到了一个与 gRPC 相关的奇怪错误。我假设这个错误是由于 gRPC 版本冲突而发生的。那么任何人都可以帮助解决这个问题吗?

应用级 build.gradle 文件:


apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    dataBinding {
        enabled = true
    }

    defaultConfig {
        applicationId "com.nsl_moca"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 12
        versionName "1.1.12"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }

    buildFeatures {
    }

    buildTypes {
        release {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
        useIR = true
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
    }
    composeOptions {
        kotlinCompilerVersion '1.4.30'
    }

}
     protobuf {
    protoc { artifact = 'com.google.protobuf:protoc:3.12.0' }
    plugins {
        javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
        grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.37.0' }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                javalite {}
                grpc { option 'lite' }
            }
        }
    }

    dependencies {
        implementation 'com.google.firebase:firebase-inappmessaging-display:19.1.5'
        implementation 'com.google.android.material:material:1.4.0-alpha01'
        implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
        implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
        implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
        implementation 'com.github.prolificinteractive:material-calendarview:2.0.0'
        implementation 'com.evrencoskun.library:tableview:0.8.9.2'
        implementation 'androidx.recyclerview:recyclerview:1.2.0'
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        implementation 'androidx.cardview:cardview:1.0.0'
        implementation 'com.koushikdutta.ion:ion:2.1.6'
        implementation files('libs/accessory-v2.6.1.jar')
        implementation files('libs/sdk-v1.0.0.jar')
        implementation 'com.google.android.gms:play-services-auth:19.0.0'
        implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') { exclude group: 'org.apache.httpcomponents' }
        implementation('com.google.http-client:google-http-client-gson:1.26.0') { exclude group: 'org.apache.httpcomponents' }
        implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'androidx.test.ext:junit:1.1.2'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
        implementation 'com.opencsv:opencsv:3.9'
        implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
        implementation 'com.jjoe64:graphview:4.2.2'
        implementation('org.apache.httpcomponents:httpmime:4.5.12') { exclude module: "httpclient" }
        implementation('com.omertron:themoviedbapi:4.2') { exclude group: 'org.apache.httpcomponents', module: 'httpclient' exclude module: 'junit' }
        implementation 'com.google.android.gms:play-services-maps:17.0.0'
        implementation 'com.google.android.gms:play-services-location:18.0.0'
        implementation 'io.grpc:grpc-okhttp:1.37.0'
        implementation 'io.grpc:grpc-protobuf-lite:1.37.0'
        implementation 'io.grpc:grpc-stub:1.37.0'
        implementation 'javax.annotation:javax.annotation-api:1.3.2'
        implementation 'com.google.android.material:material:1.3.0'
        implementation 'com.google.mlkit:face-detection:16.0.5'
        implementation files('libs/TarsosDSP-Android-2.0.jar')
        implementation 'com.github.bumptech.glide:glide:4.8.0'
        implementation 'com.google.firebase:firebase-analytics:18.0.3'
        implementation 'com.google.firebase:firebase-messaging:21.1.0'
        implementation 'org.slf4j:slf4j-jdk14:1.7.30'
        implementation 'com.squareup.okhttp3:okhttp:4.8.1'
        implementation 'com.squareup.okhttp3:logging-interceptor:4.8.1'
        implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.8.1'
        implementation files('libs/instagram4j-develop-32d42c0-dirty.jar')
        implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.11.2'
        implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.2'
        implementation 'commons-codec:commons-codec:1.14'
        implementation platform('com.google.firebase:firebase-bom:26.8.0')
        implementation 'com.google.firebase:firebase-inappmessaging-display'
        implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
        implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'

    }

}

项目级构建 gradle 文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
    }
    ext.kotlin_version = '1.4.31'
    repositories {
        google()
        jcenter()


    }
    dependencies {

        classpath "com.android.tools.build:gradle:4.0.2"
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.11'
        classpath 'com.google.gms:google-services:4.3.5'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31"


        // 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
}

当我将 Firebase 放入应用级别 build.gradle 文件中的应用消息传递依赖项时出现错误消息:

在此处输入图像描述

标签: androidgrpcprotobuf-javafirebase-in-app-messaging

解决方案


推荐阅读