gpt4 book ai didi

android - RecyclerView ClassNotFound

转载 作者:IT老高 更新时间:2023-10-28 21:50:40 27 4
gpt4 key购买 nike

我尝试将 RecyclerView 和 CardView 添加到我的项目中

dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v13:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile project(':facebook')
}

它可以编译,但在设备上运行时出现以下异常

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.RecyclerView" on path: DexPathList[[zip file "/data/app/xxxx.apk"],nativeLibraryDirectories=[/data/app-lib/xxxx, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.view.LayoutInflater.createView(LayoutInflater.java:559)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)

最佳答案

您的布局有问题。改变

<RecyclerView 
...

<android.support.v7.widget.RecyclerView
...

如果您以编程方式创建 RecyclerView - 请确保您有正确的导入:

import android.support.v7.widget.RecyclerView;

关于android - RecyclerView ClassNotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26604525/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com