当前位置: 首页 > 知识库问答 >
问题:

在我的android应用程序中添加dialogflow依赖项后出现重复类错误

蒯慈
2023-03-14

在添加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'

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

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

但它导致应用程序在启动时崩溃,产生了以下错误:

ClassNotFoundException:没有找到类“com.google.common.base.preconditions”

共有1个答案

农诚
2023-03-14

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

android {
    ... 

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

在我以前的实现中,我排除了guava模块,这是导致应用程序崩溃的原因。幸运的是,把它留在里面没有导致任何重复的类

 类似资料: