【问题标题】:android.support.design.widget class not found找不到 android.support.design.widget 类
【发布时间】:2019-11-10 01:12:45
【问题描述】:

我在 Android Studio 中遇到了这个错误:

找不到以下类:

- android.support.design.widget.FloatingActionButton(修复构建路径、编辑 XML、创建类) - android.support.design.widget.TextInputLayout(修复构建路径、编辑 XML、创建类)

这是我的 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'
    }

我已尝试将 com.android.support:design 添加到 gradle 文件中,但仍然无法解决我的问题

【问题讨论】:

    标签: android android-studio gradle android-library


    【解决方案1】:

    试试这个:

    com.google.android.material:material:1.0.0-rc01
    

    改为

    com.android.support:design
    

    【讨论】:

    • 问题依旧
    • 我已将 implementation 'com.android.support:design:27.1.1' 更改为 implementation 'com.google.android.material:material:1.0 .0-rc01'
    • 修改类和xml中的导入,然后清理并重建项目。
    【解决方案2】:

    我可以看到您正在使用 AndroidX 工件。如果您使用的是 AndroidX,其他依赖项也应该是 AndroidX!

    AndroidX 之前的版本:

    com.android.support:design
    

    AndroidX:

    com.google.android.material:material:1.0.0-rc01
    

    您还可以查看 here 以查看与之前的工件等效的 AndroidX

    【讨论】:

      【解决方案3】:

      除了@Amirhosein Heydari 的回答,别忘了在你的 XML 中添加 com.google.android.material.floatingactionbutton.FloatingActionButton

      【讨论】:

        【解决方案4】:

        我使缓存无效/重新启动并且它起作用了。转到文件 > 使缓存无效/重新启动

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-06-20
          • 1970-01-01
          • 2015-10-15
          • 1970-01-01
          • 1970-01-01
          • 2020-10-15
          • 2020-07-03
          • 1970-01-01
          相关资源
          最近更新 更多