首页 > 解决方案 > Dialogflow SDK 上的单个 dex 文件中无法容纳请求的类(#方法:156179 > 65536)

问题描述

我正在关注关于如何在 android 应用程序上实现对话框流的 2018 年教程。但是当我按照该教程进行操作时,我在放置依赖项时偶然发现了一个问题。

这就是我的 build.gradle 文件的样子


android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.specialgift"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/INDEX.LIST'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


    implementation 'ai.api:sdk:2.0.7@aar'
    implementation 'ai.api:libai:1.6.12'

    implementation 'com.google.cloud:google-cloud-dialogflow:0.67.0-alpha'
    implementation 'io.grpc:grpc-okhttp:1.15.1'


}

我收到一条错误消息说

无法在单个 dex 文件中容纳请求的类(# 方法:156179 > 65536)

在寻找其他较新的教程后,我发现了来自 dialogflow-android github 页面的消息,我总结说 android sdk 自 2019 年 10 月(即创建教程之后)以来已被弃用。从 dialogflow 文档页面,我找不到任何 android sdk 文档。

SDK 是否已被弃用或有其他解决方案来解决此错误?

标签: androiddialogflow-es

解决方案


该错误与弃用无关,它只是意味着您需要在您的应用程序中启用 Multidex


推荐阅读