[英]android.support.design.widget class not found
I'm encountering this error in Android Studio:我在 Android Studio 中遇到此错误:
The following classes could not be found:找不到以下类:
- android.support.design.widget.FloatingActionButton (Fix Build Path, Edit XML, Create Class) - android.support.design.widget.TextInputLayout (Fix Build Path, Edit XML, Create Class) - android.support.design.widget.FloatingActionButton(修复构建路径,编辑 XML,创建类) - android.support.design.widget.TextInputLayout(修复构建路径,编辑 XML,创建类)
Here are the dependencies of my build.gradle file:这是我的 build.gradle 文件的依赖项:
dependencies {
compile 'com.firebaseui:firebase-ui:0.6.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.android.support:design:27.1.1'
}
I've tried adding com.android.support:design into the gradle file but it still doesn't solve my problem我已经尝试将com.android.support:design添加到 gradle 文件中,但它仍然没有解决我的问题
Try this:尝试这个:
com.google.android.material:material:1.0.0-rc01
instead反而
com.android.support:design
I can see you are using AndroidX artifacts.我可以看到您正在使用 AndroidX 工件。 If you are using AndroidX, the other dependencies should be AndroidX as well!如果您使用的是 AndroidX,那么其他依赖项也应该是 AndroidX!
Pre-AndroidX: AndroidX 之前:
com.android.support:design
AndroidX:安卓X:
com.google.android.material:material:1.0.0-rc01
You can also check out here to see the AndroidX equivalent of the previous artifacts您还可以查看此处查看与之前工件等效的 AndroidX
除了@Amirhosein Heydari 的回答之外,不要忘记在您的 XML 中添加com.google.android.material.floatingactionbutton.FloatingActionButton
。
I invalidated cache/restarted and it worked.我使缓存无效/重新启动并且它起作用了。 Go to file > Invalidate cache/restart转到文件 > 使缓存无效/重新启动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.