本文介绍了更新了Firebase依赖性,并获得了重复的Protobuf类错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新其中一个Firebase SDK后出现此错误

I'm getting this error after updating one of my firebase SDKs

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.protobuf.AbstractMessageLite found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
  Duplicate class com.google.protobuf.AbstractMessageLite$Builder found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
  Duplicate class com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
  Duplicate class com.google.protobuf.AbstractParser found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
  Duplicate class com.google.protobuf.AbstractProtobufList found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
  Duplicate class com.google.protobuf.BooleanArrayList found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
  Duplicate class com.google.protobuf.ByteBufferWriter found in modules jetified-protobuf-javalite-3.11.0.jar (com.google.protobuf:protobuf-javalite:3.11.0) and jetified-protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
...

我的应用现在依赖于 protobuf-lite protobuf-javalite ,这会触发重复的类错误.

My app now depends on protobuf-lite and protobuf-javalite, which triggers the duplicate class error.

推荐答案

最近,Firebase Android已从依靠旧的 protobuf-lite 迁移到依靠 protobuf-javalite >( github问题 | 实施更改的公关).

Recently, Firebase Android has migrated from depending on the old protobuf-lite to depend on protobuf-javalite (github issue | PR implementing the change).

您需要同时更新受此更改影响的所有firebase SDK ,否则旧的SDK将错误的依赖关系拖入您的应用.

You need to update all the firebase SDKs affected by this change together, otherwise the old SDKs will pull the wrong dependency into your app.

以下是受影响的SDK及其支持 protobuf-javalite

Here is the list of affected SDKs and their versions supporting protobuf-javalite

- com.google.firebase:firebase-firestore:21.5.0
- com.google.firebase:firebase-inappmessaging:19.1.0
- com.google.firebase:firebase-inappmessaging-display:19.1.0
- com.google.firebase:firebase-config:19.2.0
- com.google.firebase:firebase-abt:19.1.0
- com.google.firebase:firebase-perf:19.0.8

firebase-perf 添加到列表中,因为它暂时取决于配置,并且还需要更新.

Added firebase-perf to the list, as it transitively depends on config and also needs to be updated.

这篇关于更新了Firebase依赖性,并获得了重复的Protobuf类错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 10:40