简体   繁体   English

无法导入导入android.support.v7.widget.RecyclerView;

[英]Cannot import import android.support.v7.widget.RecyclerView;

While learning about RecyclerView, I am facing some problem. 在学习RecyclerView时,我遇到了一些问题。 GreenAdapter Class failed to import “android.support.v7.widget.RecyclerView”. GreenAdapter类无法导入“ android.support.v7.widget.RecyclerView”。 I am using Android Studio 3.1.4. 我正在使用Android Studio 3.1.4。 My compile SDK Version is 28. Here's my build.gradle File: 我的编译SDK版本是28。这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28



    defaultConfig {
        applicationId "com.example.sunshine.sunshine.app"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"


    }

    buildTypes {
       release {
           minifyEnabled false
           proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }

}

dependencies {
    implementation project(':sunshinemodule')
    implementation project(':base')

    implementation 'com.android.support:design:28.0.0-rc01'
}

I am also sharing the code where the import is not working: 我还在共享导入无效的地方共享代码:

在此处输入图片说明

You should add 您应该添加

implementation 'com.android.support:recyclerview-v7:27.1.1' //28.0.0-rc01

After that, Clean-rebuild and Run . 之后, Clean-rebuildRun

Add this to your gradle: 将此添加到您的gradle:

implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

and then click "Sync now". 然后单击“立即同步”。

Right click on app --> Open Module Settings --> Dependencies then on right side click on plus button. 右键单击应用程序->打开模块设置->依赖关系,然后在右侧单击加号按钮。 Add library dependency and search recyclerview and then add it. 添加库依赖关系并搜索recyclerview,然后添加它。 在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法导入:Android Studio 中的 android.support.v7.widget.RecyclerView - Can't import: android.support.v7.widget.RecyclerView in Android Studio android.support.v4.widget.NestedScrollView无法转换为android.support.v7.widget.RecyclerView - android.support.v4.widget.NestedScrollView cannot be cast to android.support.v7.widget.RecyclerView android.support.v7.widget.RecyclerView无法强制转换为android.widget.ListView - android.support.v7.widget.RecyclerView cannot be cast to android.widget.ListView android.widget.LinearLayout 不能转换为 android.support.v7.widget.RecyclerView - android.widget.LinearLayout cannot be cast to android.support.v7.widget.RecyclerView RecyclerView没有LayoutManager android.support.v7.widget.RecyclerView - RecyclerView has no LayoutManager android.support.v7.widget.RecyclerView '布尔android.support.v7.widget.RecyclerView $ LayoutManager.canScrollVertically()' - 'boolean android.support.v7.widget.RecyclerView$LayoutManager.canScrollVertically()' android.support.v7.widget.RecyclerView无法实例化 - android.support.v7.widget.RecyclerView failed to instantiate eclipse中无法启动android.support.v7.widget.Recyclerview错误 - android.support.v7.widget.Recyclerview could not be initiated error in eclipse 找不到以下类: - android.support.v7.widget.RecyclerView - The following classes could not be found: - android.support.v7.widget.RecyclerView java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams 不能转换为 android.support.v7.widget.RecyclerView$LayoutParams - java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v7.widget.RecyclerView$LayoutParams
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM