Android-在protobuf-java-3.8.0.jar和protobuf-lite-3.0.1.jar模块中发现重复类

Android-在protobuf-java-3.8.0.jar和protobuf-lite-3.0.1.jar模块中发现重复类,java,android,google-cloud-platform,Java,Android,Google Cloud Platform,我正在使用谷歌语音github android项目。在升级了所有的文件版本后,它最终设法解决了一个问题,我无法解决它。 此处显示错误消息: Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-3.8.0.jar (com.google.protobuf:protobuf-java:3.8.0) and protobuf-lite-3.0.1.jar (com.google.p

我正在使用谷歌语音github android项目。在升级了所有的文件版本后,它最终设法解决了一个问题,我无法解决它。 此处显示错误消息:

Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-3.8.0.jar (com.google.protobuf:protobuf-java:3.8.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
还有数百行类似的警告

为了解决这个问题,我尝试了很多其他版本的“io.grpc:grpc-protobuf-lite:1.21.0”和“com.google.protobuf:protobuf-java:3.8.0”,通过更改它们的数字,但没有任何匹配的方法,我不断收到错误消息

奇怪的事实是:升级3.0.1版本的“io.grpc:grpc protobuf lite:--”会出现以下错误:
错误:无法解析:io.grpc:grpc protobuf lite:3.0.1
在“项目结构”对话框中显示
受影响模块:应用程序
但将其保留在1.21.0版本不会产生任何错误,但会显示重复的错误消息,该消息显然包含不存在的3.0.1版本

以下是我的gradle中的依赖项列表:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Support libraries
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:cardview-v7:$supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"

// gRPC
implementation "io.grpc:grpc-okhttp:$grpcVersion"
implementation "io.grpc:grpc-stub:$grpcVersion"
implementation "io.grpc:grpc-protobuf-lite:3.0.1"

implementation 'javax.annotation:javax.annotation-api:1.2'
implementation 'com.google.protobuf:protobuf-java:3.8.0'

// OAuth2 for Google API
implementation('com.google.auth:google-auth-library-oauth2-http:0.16.0') {
    exclude module: 'httpclient'
}

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

如何解决此重复错误消息?

有时删除重复的R.java和BuildConfig文件可能会解决此问题,但如果它对我没有帮助,因为它总是重新创建并显示上述错误

我也遇到过同样的问题,帮助我理解为什么文件最初是重复的。但我意识到这是因为我错误地在项目中的模块之间建立了循环依赖关系。 当编译器开始为它已经编译为依赖项的其中一个模块创建类时,通过这样做,它显示了错误。
因此,删除不必要的依赖项并重新编译项目解决了问题。

可能您将依赖项方法与资源混淆了。这个项目中有什么不需要的东西可以删除?我认为R.java与这个错误无关。这与资源无关。为什么要使用lite和protobuf的完整版本?只选择一个,然后删除另一个。嘿,谢谢。这一切都在那个项目中。两个版本都有。删除lite版本破坏了项目。删除非精简版本解决了此问题。不客气,很高兴在添加翻译客户端依赖项后修复了此问题。此Duplicate类错误消息再次出现。它是什么依赖项?