我收到错误
The following classes could not be found:
- android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)
- android.support.design.widget.NavigationView (Fix Build Path, Edit XML, Create Class)
- android.support.v4.widget.DrawerLayout (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project.
这是我的模块应用程序:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
我尝试过重建、清理和更改实现,但似乎没有任何效果
有人知道我该如何解决这个问题吗?当我更新 android studio 并创建一个新项目时,它就开始了。
最佳答案
您的依赖项混合了支持库和 AndroidX,这是不正确的。使用 Android Studio 将其重构为 AndroidX。
重构 > 迁移到 AndroidX 并按执行重构
你必须使用
androidx.coordinatorlayout.widget.CoordinatorLayout
com.google.android.material.navigation.NavigationView
androidx.drawerlayout.widget.DrawerLayout
而不是
android.support.design.widget.CoordinatorLayout
android.support.design.widget.NavigationView
android.support.v4.widget.DrawerLayout
关于java - 无法找到以下类错误(最新版本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58466862/