AndroidX-程序类型已存在:androidx.annotation.BoolRes [英] AndroidX - Program type already present: androidx.annotation.BoolRes

查看:409
本文介绍了AndroidX-程序类型已存在:androidx.annotation.BoolRes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried to migrate my current project today to AndroidX using the "Refactor - > Migrate to AndroidX" option in Android Studio and whenever I try to compile my application, I receive a

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

Program type already present: androidx.annotation.BoolRes

AGPBI:{种类":错误",文本":程序类型已存在:androidx.annotation.BoolRes",源":[{}],工具":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug失败 :app:buildInfoGeneratorDebug 失败:生成失败,发生异常. * 什么地方出了错: 任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败.

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依赖项.

I used ./gradlew app:dependencies to fetch my list of dependencies, but it seems a lot of libraries are using the new androidx.annotation:annotation:1.0.0 dependency.

//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有关:

The problem seems to be related to the renderscript api in my build.gradle file:

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
}

从块中删除renderscriptSupportModeEnabledrenderscriptTargetApi似乎可以解决此问题.

Removing the renderscriptSupportModeEnabled and renderscriptTargetApi from the block seems to fix the issue.

这篇关于AndroidX-程序类型已存在:androidx.annotation.BoolRes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆