无法解析导入 androidx.appcompat.widget.AppCompatImageView 的符号“widget”;

问题描述 投票:0回答:1

我目前正在将我的项目迁移到 Androidx,在 android studio 中使用重构选项后,我在类中仍然很少支持 lib 导入。 当我尝试更改 'import android.support.v7.widget.AppCompatImageView;' 时到“导入 androidx.appcompat.widget.AppCompatImageView;”,我得到以下编译错误

Cannot resolve symbol 'widget'

我目前正在使用“Android Studio Electric Eel | 2022.1.1(2023 年 1 月)' 并且所有支持依赖项均替换为 androidx。

android widget androidx
1个回答
0
投票

听起来 appcompat 库没有正确添加到您的 Gradle 依赖项中。

如 Android 开发者网站上的 appcompat 页面所述,将以下内容添加到应用程序级 build.gradle 的

dependencies {
块中:

def appcompat_version = "1.6.1" // or whatever the latest version is on the above-linked page

implementation "androidx.appcompat:appcompat:$appcompat_version"
// For loading and tinting drawables on older versions of the platform
implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
© www.soinside.com 2019 - 2024. All rights reserved.