gpt4 book ai didi

java - 将 dialogflow 依赖项添加到我的 android 应用程序后出现重复类错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:21:01 30 4
gpt4 key购买 nike

向使用 firebase 的应用程序添加 dialogflow 依赖项后,出现重复类错误。

尝试降级 dialogflow 和 firebase 依赖项,也尝试过

"implementation('com.google.cloud:google-cloud-dialogflow:0.98.0-alpha'){
exclude group: 'com.google.api.grpc'
exclude group: 'com.google.protobuf'
}"

排除重复类。这些都不起作用!

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.google.firebase:firebase-firestore:20.1.0'
implementation "com.github.VaibhavLakhera:Circular-Progress-View:0.1.2"
implementation 'com.github.CardinalNow:Android-CircleProgressIndicator:v0.2'
implementation 'ai.api:sdk:2.0.7@aar'
implementation 'ai.api:libai:1.6.12'
implementation 'com.google.cloud:google-cloud-dialogflow:0.98.0-alpha'
implementation 'io.grpc:grpc-okhttp:1.21.0'
implementation 'com.google.apis:google-api-services-oauth2:v1-rev145-1.25.0'
implementation 'com.google.apis:google-api-services-dialogflow:v2-rev80-1.25.0'
implementation "com.andkulikov:transitionseverywhere:2.0.0-beta01"
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'

错误:

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) Blockquote

我能够使用以下方法排除重复类:

android {
...
configurations {
implementation.exclude module:'proto-google-common-protos'
implementation.exclude module:'protolite-well-known-types'
implementation.exclude module:'guava'
implementation.exclude module:'protobuf-lite'
}
}

但它导致应用程序在启动时崩溃并产生此错误:

java.lang.ClassNotFoundException: Didn't find class "com.google.common.base.Preconditions"

最佳答案

要排除导致问题的重复类,请将以下代码发布到您的 build.gradle(应用模块)文件中:

android {
...

configurations {
implementation.exclude module:'proto-google-common-protos'
implementation.exclude module:'protolite-well-known-types'
implementation.exclude module:'protobuf-lite'
}
}

在我之前的实现中,我排除了导致应用程序崩溃的 guava 模块。幸运的是,保留它不会导致任何重复的类

关于java - 将 dialogflow 依赖项添加到我的 android 应用程序后出现重复类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56811328/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com