gpt4 book ai didi

AndroidX - 程序类型已经存在 : androidx. annotation.BoolRes

转载 作者:行者123 更新时间:2023-11-29 14:34:42 27 4
gpt4 key购买 nike

我今天尝试使用 Android Studio 中的“重构 -> 迁移到 AndroidX”选项将我当前的项目迁移到 AndroidX,每当我尝试编译我的应用程序时,我都会收到一个

Program type already present: androidx.annotation.BoolRes

AGPBI: {"kind":"error","text":"Program type already present: androidx.annotation.BoolRes","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED :app:buildInfoGeneratorDebug FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

我使用 ./gradlew app:dependencies 来获取我的依赖项列表,但似乎很多库都在使用新的 androidx.annotation:annotation:1.0.0依赖。

//Android
implementation "androidx.constraintlayout:constraintlayout:$constraintLayout"
implementation "androidx.cardview:cardview:$androidX"
implementation "androidx.recyclerview:recyclerview:$androidX"
implementation "androidx.annotation:annotation:1.0.0"

//Material
implementation "com.google.android.material:material:$material"

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle"

//Room
implementation "androidx.room:room-runtime:$room"
annotationProcessor "androidx.room:room-compiler:$room"

最佳答案

问题似乎与我的 build.gradle 文件中的 renderscript api 有关:

defaultConfig {
applicationId "xxx"
minSdkVersion 23
targetSdkVersion 28
versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
renderscriptTargetApi 28
renderscriptSupportModeEnabled true
}

从 block 中删除 renderscriptSupportModeEnabledrenderscriptTargetApi 似乎可以解决问题。

关于AndroidX - 程序类型已经存在 : androidx. annotation.BoolRes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52533779/

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