gpt4 book ai didi

android - 类描述符 'Landroid/support/customtabs/ICustomTabsCallback/;'不能用dex格式表示

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:37:53 26 4
gpt4 key购买 nike

我将我的 android studio 更新到版本 3.3 canary 13(撰写本文时为最新版本)。我被提示更新我的项目的 gradle 版本,我将它更新到版本 3.3.0-alpha13

类路径 'com.android.tools.build:gradle:3.3.0-alpha13'

现在当我尝试运行我的项目时,它因错误而失败

错误:类描述符“Android/support/customtabs/ICustomTabsCallback/;”不能用dex格式表示。

我尝试使缓存无效、清理并重建项目,但没有任何效果。下面是我的应用程序的 build.gradle

dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha3', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'

}

最佳答案

我决定尝试使用 ./gradlew build --stacktrace 命令,发现 ICustomTabsCallback 类正在被 androidx.browser:browser:1.0.0 使用-rc01 库。

> Transform browser.aar (androidx.browser:browser:1.0.0-rc01) with DexingTransform
AGPBI: {"kind":"error","text":"Class descriptor \u0027Landroid/support/customtabs/ICustomTabsCallback/;\u0027 cannot be represented in dex format.","sources":[{}],"tool":"D8"}

> Task :app:mergeExtDexDebug FAILED
AGPBI: {"kind":"error","text":"Class descriptor \u0027Landroid/support/customtabs/ICustomTabsCallback/;\u0027 cannot be represented in dex format.","sources":[{}],"tool":"D8"}

FAILURE: Build failed with an exception.

然后我使用 ./gradlew app:dependencies 命令查看依赖项是否存在冲突,我发现了错误。

 +--- androidx.appcompat:appcompat:1.0.0-rc01 -> 1.0.0 (*)
| \--- androidx.browser:browser:1.0.0-rc01
| +--- androidx.core:core:1.0.0-rc01 -> 1.0.0 (*)
| +--- androidx.annotation:annotation:1.0.0-rc01 -> 1.0.0
| +--- androidx.interpolator:interpolator:1.0.0-rc01 -> 1.0.0 (*)
| +--- androidx.collection:collection:1.0.0-rc01 -> 1.0.0 (*)
| \--- androidx.legacy:legacy-support-core-ui:1.0.0-rc01 -> 1.0.0 (*)

上面的摘录显示了 debugCompileClasspath 配置的一些依赖关系。我们可以看到 androidx.appcompat:appcompat 包含 androidx.browser:browser 作为传递依赖。

androidx.appcompat:appcompat:1.0.0-rc01 -> 1.0.0 表示将使用版本 1.0.0 而不是版本 1.0。 0-rc01androidx.browser:browser 不是这种情况。将使用版本 1.0.0-rc01 而不是版本 1.0.0

为了解决这个错误,我只是通过在我的应用程序的 build.gradle

中添加以下代码块来删除传递依赖项
configurations {
compile.exclude group: 'androidx.browser', module: 'browser'
}

所以我的应用程序的 build.gradle 看起来像这样

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

android {
//....
}

configurations {
compile.exclude group: 'androidx.browser', module: 'browser'
}

dependencies {
// ....
}

在那之后,我只是同步、清理并重建了我的项目。

更新

如果答案没有解决您的问题,另一种选择是使用 android studio 稳定版(根据本文编写的 3.2.1)和 gradle 3.2.1 classpath 'com.android.tools.build: gradle:3.2.1'

关于android - 类描述符 'Landroid/support/customtabs/ICustomTabsCallback/;'不能用dex格式表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52639577/

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