Duplicate Class while using firebase and google-cloud-texttospeech(在使用Firebase和Google-Cloud-Texttospeech时复制类)
问题描述
我有一个使用Firestore、Firebase-auth和FCM的Android项目。现在,当我在我的项目中添加google-cloud-exttospeech时,我收到了‘Duplate Class’错误
以下是我的依赖项
//Firebase
implementation "com.google.firebase:firebase-core:17.0.0"
implementation "com.google.firebase:firebase-firestore:20.1.0"
/*implementation "com.crashlytics.sdk.android:crashlytics:$rootProject.crashlytics"*/
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation "com.google.firebase:firebase-auth:18.0.0"
// Ad-mob
implementation "com.google.android.gms:play-services-ads:18.0.0"
implementation ("com.google.cloud:google-cloud-texttospeech:0.97.0-beta")
这是我在生成项目时收到的错误。
Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AdviceOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AnnotationsProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProviderOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirementOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthenticationOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthenticationRule found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
现在我了解到Firebase和Google-Cloud-exttospeech在这两个依赖项中使用了相同的类。 所以我试着通过
来排除它们implementation ("com.google.cloud:google-cloud-texttospeech:0.97.0-beta"){
exclude group: 'com.google.api.grpc', module: 'proto-google-common-protos'
exclude group: 'com.google.protobuf', module: 'protobuf-lite'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
然后应用程序正在构建,但在语音合成时崩溃
2019-07-03 20:04:15.861 24851-24851/package.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: package.dev, PID: 24851
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/protobuf/GeneratedMessageV3;
at com.google.cloud.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101)
at package_name.tts.TextSpeachAPI.<init>(TextSpeachAPI.kt:8)
at package_name.ui.home.sofar.WordDetailsVM.speak(WordDetailsVM.kt:318)
at package_name.ui.home.sofar.WordDetailsFragment$listeners$11.onClick(WordDetailsFragment.kt:264)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.protobuf.GeneratedMessageV3" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/package_name.dev-apgPZPeLvH3LUXKWw2gBbg==/base.apk"],nativeLibraryDirectories=[/data/app/package_name.dev-apgPZPeLvH3LUXKWw2gBbg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.cloud.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101)
at package_name.tts.TextSpeachAPI.<init>(TextSpeachAPI.kt:8)
at package_name.ui.home.sofar.WordDetailsVM.speak(WordDetailsVM.kt:318)
at package_name.ui.home.sofar.WordDetailsFragment$listeners$11.onClick(WordDetailsFragment.kt:264)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
推荐答案
我在使用谷歌云语音时遇到了这样的问题。 在"Firestore"和"Google Cloud Speech"的使用中,我显示了"Protobuf-Java"、"Protobuf-lite"、"proto-Google-Common-Protos"和"protolite-熟知-Types"中的重复类。我通过解压缩JAR文件并创建一个没有重复类的新JAR文件解决了这个问题。请参考我在下面发布的GitHub项目。
https://github.com/ivso0001/GoogleCloudSpeechAndFirebaseIntegration
这篇关于在使用Firebase和Google-Cloud-Texttospeech时复制类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在使用Firebase和Google-Cloud-Texttospeech时复制类
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01