首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在android应用程序中与protobuf一起使用Firebase BOM(Firebae)时出现重复类问题

在android应用程序中与protobuf一起使用Firebase BOM(Firebae)时出现重复类问题
EN

Stack Overflow用户
提问于 2021-03-12 12:45:50
回答 1查看 210关注 0票数 0

我在我的安卓应用程序中使用proto。现在我尝试在firebase-pref.中使用firebase BOM(26.6.0)

当我运行构建,得到重复的类问题。build.gradle -

代码语言:javascript
复制
dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation platform('com.google.firebase:firebase-bom:26.6.0')
    implementation "com.google.firebase:firebase-appindexing"
    //implementation "com.google.firebase:firebase-database:19.2.0"
    implementation 'com.google.firebase:firebase-database-ktx'
    implementation "com.google.firebase:firebase-auth"
    implementation "com.google.firebase:firebase-analytics"
    implementation ("com.google.firebase:firebase-perf")
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation "com.google.protobuf:protobuf-lite:3.0.1"
}

protobuf {
    protoc {
        // You still need protoc like in the non-Android case
        artifact = 'com.google.protobuf:protoc:3.7.0'
    }
    plugins {
        javalite {
            // The codegen for lite comes as a separate artifact
            artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                // In most cases you don't need the full Java output
                // if you use the lite output.
                remove java
            }
            task.plugins {
                javalite { }
            }
        }
    }
}

sourceSets{
    main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/javalite"
}

试评

"com.google.protobuf:protobuf-lite:3.0.1"实现和使用实现'com.google.protobuf:protobuf-javalite:3.14.0'

它也不起作用。是否可以建议任何工作,以便我可以使用更新的防火墙以及保持原版使用不变。

EN

Stack Overflow用户

发布于 2021-06-28 02:40:49

becase原生质体:3.0.1和原生质体-javalite:3.14.0都有一个名为com.google.protobuf.AbstractMessageLite的类。但是类代码不兼容。有些不同之处如下:

在javalite中:3.14.0 AbstractMessageLite有一个接口

代码语言:javascript
复制
protected interface InternalOneOfEnum {
    int getNumber();
}

但原生质体中的AbstractMessageLite :3.0.1没有界面.

所以解决这个问题的唯一方法就是删除一个原型。添加、排除(如exclude group: 'com.*.*' )不适用于此问题。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66600185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档