找不到类的android.support.v4.widget.SwipeRefreshLayout“ [英] Could not find class 'android.support.v4.widget.SwipeRefreshLayout'

查看:870
本文介绍了找不到类的android.support.v4.widget.SwipeRefreshLayout“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到此错误,这是造成我的应用程序崩溃。试图实施新的V4刷卡刷新布局。我已经更新了支持库+ SDK。问题是什么?

找不到类的android.support.v4.widget.SwipeRefreshLayout,从方法引用......的onCreate

 进口android.support.v4.widget.SwipeRefreshLayout;
...
私人SwipeRefreshLayout swipeLayout;

@覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);

    的setContentView(R.layout.home_page_list);
swipeLayout =(SwipeRefreshLayout)findViewById(R.id.container);
    swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    swipeLayout.setOnRefreshListener(新SwipeRefreshLayout.OnRefreshListener(){
        @覆盖
        公共无效onRefresh(){
            swipeLayout.setRefreshing(假);
        }
    });
 

XML

 < android.support.v4.widget.SwipeRefreshLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
的xmlns:工具=htt​​p://schemas.android.com/tool​​s
机器人:ID =@ + ID /容器
机器人:layout_width =match_parent
机器人:layout_height =match_parent
工具:上下文=com.devrim.ythaber.HomeActivity
工具:忽略=MergeRootFrame>

<滚动型
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT>

    <的LinearLayout
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直>

        < ImageView的
            机器人:ID =@ + ID /拇指
            机器人:layout_width =100dp
            机器人:layout_height =100dp
            机器人:contentDescription =@字符串/ APP_NAME/>

        < RelativeLayout的
            机器人:ID =@ + ID / relativeLayout1
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =290dp
            机器人:layout_centerVertical =真
            机器人:layout_marginLeft =5DP
            机器人:layout_marginRight =5DP
            机器人:方向=垂直>

            !<  - 安卓layout_toRightOf =@ + ID /拇指 - >

        < / RelativeLayout的>

        <的TextView
            机器人:ID =@ + ID /标题
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_gravity =左
            机器人:ellipsize =结束
            机器人:fontFamily中=无衬线光
            机器人:MAXLINES =2
            机器人:则shadowColor =@色/阴影的
            机器人:shadowDx =2
            机器人:shadowDy =2
            机器人:shadowRadius =2
            机器人:文本=@字符串/标题
            机器人:textAllCaps =假
            机器人:textAppearance =机器人:ATTR / textAppearanceSmallPopupMenu
            机器人:文字颜色=@色/ titlecolour
            机器人:TEXTSIZE =35SP
            机器人:TEXTSTYLE =斜体
            机器人:字体=SANS>
        < / TextView的>

        <的TextView
            机器人:ID =@ + ID /类别
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_below =@ + ID /标题
            机器人:ellipsize =结束
            机器人:fontFamily中=无衬线光
            机器人:重力=右
            机器人:MAXLINES =1
            机器人:paddingRight =5DP
            机器人:paddingTop =10dp
            机器人:textAppearance =机器人:ATTR / textAppearanceSmallPopupMenu
            机器人:文字颜色=@色/ catcolour
            机器人:TEXTSIZE =17sp
            机器人:TEXTSTYLE =斜体
            机器人:字体=SANS>
        < / TextView的>
    < / LinearLayout中>
< /滚动型>
< /android.support.v4.widget.SwipeRefreshLayout>
 

完成logcat的:

  05-01 21:31:27.390:W / dalvikvm(11452):VFY:找不到签名中引用的类(Landroid /支持/ V4 /空间/ SwipeRefreshLayout;)
05-01 21:31:27.390:E / dalvikvm(11452):找不到类的android.support.v4.widget.SwipeRefreshLayout,从法com.devrim.ythaber.HomeActivity.onCreate引用
05-01 21:31:27.390:W / dalvikvm(11452):VFY:无法解决入住投619(Landroid /支持/ V4 /空间/ SwipeRefreshLayout;)在LCOM / devrim / ythaber / HomeActivity;
05-01 21:31:27.390:W / dalvikvm(11452):类的链接LCOM / devrim / ythaber / HomeActivity $ 1;'失败
05-01 21:31:27.440:W / dalvikvm(11452):主题ID = 1:螺纹退出与未捕获的异常(组= 0x4166ee18)
05-01 21:31:27.440:E / AndroidRuntime(11452):致命异常:主要
05-01 21:31:27.440:E / AndroidRuntime(11452):工艺:com.devrim.ythaber,PID:11452
05-01 21:31:27.440:E / AndroidRuntime(11452):java.lang.NoClassDefFoundError的:android.support.v4.widget.SwipeRefreshLayout
05-01 21:31:27.440:E / AndroidRuntime(11452):在com.devrim.ythaber.HomeActivity.onCreate(HomeActivity.java:56)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.Activity.performCreate(Activity.java:5312)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.ActivityThread.access $ 800(ActivityThread.java:156)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1355)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.os.Handler.dispatchMessage(Handler.java:102)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.os.Looper.loop(Looper.java:157)
05-01 21:31:27.440:E / AndroidRuntime(11452):在android.app.ActivityThread.main(ActivityThread.java:5872)
05-01 21:31:27.440:E / AndroidRuntime(11452):在java.lang.reflect.Method.invokeNative(本机方法)
05-01 21:31:27.440:E / AndroidRuntime(11452):在java.lang.reflect.Method.invoke(Method.java:515)
05-01 21:31:27.440:E / AndroidRuntime(11452):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1069)
05-01 21:31:27.440:E / AndroidRuntime(11452):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)
 

解决方案

对于我来说,问题是,我的库项目之一是使用 V13 的支持库: Android的支持 - v13.jar

所以看出来像这样在日志中的消息:

 这两个Android的支持,V4和Android支持-V13在依赖列表中找到。
由于V13包括V4,只使用V13。
 

如果您看到警告,请确保您的库项目还包括了最新的支持库,否则您的 V4 库可能会被一个老的 V13 库取代(这明显不包括新的 SwipeRefreshLayout )。

I keep getting this error and it's causing my app to crash. Trying to implement the new v4 swipe refresh layout. I have updated the support library + sdk. What is the issue?

Could not find class 'android.support.v4.widget.SwipeRefreshLayout', referenced from method ......onCreate

import android.support.v4.widget.SwipeRefreshLayout;
...
private SwipeRefreshLayout swipeLayout;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.home_page_list);
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.container);
    swipeLayout.setColorScheme(android.R.color.holo_blue_bright, 
            android.R.color.holo_green_light, 
            android.R.color.holo_orange_light, 
            android.R.color.holo_red_light);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeLayout.setRefreshing(false);
        }
    });

XML

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.devrim.ythaber.HomeActivity"
tools:ignore="MergeRootFrame" >

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/thumb"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:contentDescription="@string/app_name" />

        <RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="wrap_content"
            android:layout_height="290dp"
            android:layout_centerVertical="true"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:orientation="vertical" >

            <!-- android:layout_toRightOf="@+id/thumb" -->

        </RelativeLayout>

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:ellipsize="end"
            android:fontFamily="sans-serif-light"
            android:maxLines="2"
            android:shadowColor="@color/dropshadow"
            android:shadowDx="2"
            android:shadowDy="2"
            android:shadowRadius="2"
            android:text="@string/title"
            android:textAllCaps="false"
            android:textAppearance="?android:attr/textAppearanceSmallPopupMenu"
            android:textColor="@color/titlecolour"
            android:textSize="35sp"
            android:textStyle="italic"
            android:typeface="sans" >
        </TextView>

        <TextView
            android:id="@+id/category"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title"
            android:ellipsize="end"
            android:fontFamily="sans-serif-light"
            android:gravity="right"
            android:maxLines="1"
            android:paddingRight="5dp"
            android:paddingTop="10dp"
            android:textAppearance="?android:attr/textAppearanceSmallPopupMenu"
            android:textColor="@color/catcolour"
            android:textSize="17sp"
            android:textStyle="italic"
            android:typeface="sans" >
        </TextView>
    </LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

Complete logcat:

05-01 21:31:27.390: W/dalvikvm(11452): VFY: unable to find class referenced in signature (Landroid/support/v4/widget/SwipeRefreshLayout;)
05-01 21:31:27.390: E/dalvikvm(11452): Could not find class 'android.support.v4.widget.SwipeRefreshLayout', referenced from method com.devrim.ythaber.HomeActivity.onCreate
05-01 21:31:27.390: W/dalvikvm(11452): VFY: unable to resolve check-cast 619 (Landroid/support/v4/widget/SwipeRefreshLayout;) in Lcom/devrim/ythaber/HomeActivity;
05-01 21:31:27.390: W/dalvikvm(11452): Link of class 'Lcom/devrim/ythaber/HomeActivity$1;' failed
05-01 21:31:27.440: W/dalvikvm(11452): threadid=1: thread exiting with uncaught exception (group=0x4166ee18)
05-01 21:31:27.440: E/AndroidRuntime(11452): FATAL EXCEPTION: main
05-01 21:31:27.440: E/AndroidRuntime(11452): Process: com.devrim.ythaber, PID: 11452
05-01 21:31:27.440: E/AndroidRuntime(11452): java.lang.NoClassDefFoundError: android.support.v4.widget.SwipeRefreshLayout
05-01 21:31:27.440: E/AndroidRuntime(11452):    at com.devrim.ythaber.HomeActivity.onCreate(HomeActivity.java:56)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.Activity.performCreate(Activity.java:5312)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.ActivityThread.access$800(ActivityThread.java:156)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.os.Looper.loop(Looper.java:157)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at android.app.ActivityThread.main(ActivityThread.java:5872)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at java.lang.reflect.Method.invokeNative(Native Method)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at java.lang.reflect.Method.invoke(Method.java:515)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069)
05-01 21:31:27.440: E/AndroidRuntime(11452):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)

解决方案

For me, the problem was that one of my library projects was using v13 of the support library: android-support-v13.jar.

So look out for a message like this in your logs:

Found both android-support-v4 and android-support-v13 in the dependency list.
Because v13 includes v4, using only v13.

If you see that warning, make sure your library project also includes the latest support library, otherwise your v4 library might get superseded by an old v13 library (which obviously does not include the new SwipeRefreshLayout).

这篇关于找不到类的android.support.v4.widget.SwipeRefreshLayout“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆