android binary xml file line,Binary XML file line #7: Error inflating class android.s

07-22 23:05:34.553:

D/AndroidRuntime(2968): Shutting down VM

07-22 23:05:34.560:

E/AndroidRuntime(2968): FATAL EXCEPTION: main

07-22 23:05:34.560:

E/AndroidRuntime(2968): Process: com.zh.myrecyclerview, PID:

2968

07-22 23:05:34.560:

E/AndroidRuntime(2968): java.lang.RuntimeException: Unable to start

activity

ComponentInfo{com.zh.myrecyclerview/com.zh.myrecyclerview

.MainActivity}:

android.view.InflateException: Binary XML file line #7: Error

inflating class android.support.v7.widget.RecyclerView

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.ActivityThread.performLaunchActivity(ActivityThread.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.ActivityThread.handleLaunchActivity(ActivityThread.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.ActivityThread.access$800(ActivityThread.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.ActivityThread$H.handleMessage(ActivityThread.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.os.Handler.dispatchMessage(Handler.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.os.Looper.loop(Looper.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.ActivityThread.main(ActivityThread.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at java.lang.reflect.Method.invoke(Native

Method)

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

com.android.internal.os.ZygoteInit.main(ZygoteInit.

07-22 23:05:34.560:

E/AndroidRuntime(2968): Caused by: android.view.InflateException:

Binary XML file line #7: Error inflating class

android.support.v7.widget.RecyclerView

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.createView(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.createViewFromTag(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.rInflate(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.inflate(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.inflate(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.inflate(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.Activity.setContentView(Activity.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

com.zh.myrecyclerview.MainActivity.onCreate(MainActivity.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.Activity.performCreate(Activity.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.Instrumentation.callActivityOnCreate(Instrumentation.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.app.ActivityThread.performLaunchActivity(ActivityThread.

07-22 23:05:34.560:

E/AndroidRuntime(2968): ... 10 more

07-22 23:05:34.560:

E/AndroidRuntime(2968): Caused by:

java.lang.reflect.InvocationTargetException

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.view.LayoutInflater.createView(LayoutInflater.

07-22 23:05:34.560:

E/AndroidRuntime(2968): ... 21 more

07-22 23:05:34.560:

E/AndroidRuntime(2968): Caused by: java.lang.NoClassDefFoundError:

Failed resolution of:

Landroid/support/v7/recyclerview/R$styleable;

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.support.v7.widget.RecyclerView.(RecyclerView.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

android.support.v7.widget.RecyclerView.(RecyclerView.

07-22 23:05:34.560:

E/AndroidRuntime(2968): ... 24 more

07-22 23:05:34.560:

E/AndroidRuntime(2968): Caused by:

java.lang.ClassNotFoundException: Didn't find class

"android.support.v7.recyclerview.R$styleable" on path:

DexPathList[[zip file

"/data/app/com.zh.myrecyclerview-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,

/system/lib]]

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): ... 26 more

07-22 23:05:34.560:

E/AndroidRuntime(2968): Suppressed:

java.lang.ClassNotFoundException:

android.support.v7.recyclerview.R$styleable

07-22 23:05:34.560:

E/AndroidRuntime(2968): at java.lang.Class.classForName(Native

Method)

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): at

07-22 23:05:34.560:

E/AndroidRuntime(2968): ... 27 more

07-22 23:05:34.560:

E/AndroidRuntime(2968): Caused by: java.lang.NoClassDefFoundError:

Class not found using the boot class loader; no stack

available

07-22 23:05:37.406: I/Process(2968):

Sending signal. PID: 2968 SIG: 9

试了很多方法都不行,整了半天,终于搞定,原来在eclipse中使用RecyclerView只能导入API21.0.0中的包才可以使用。

解决办法:进入sdk\extras\Android\m2repository\com\android\support\recyclerview-v7\21.0.0目录,找到recyclerview-v7-21.0.0.aar这个文件。用解压软件解压此文件里面有classes.jar,把这个jar包放到项目中的libs文件下即可。这个jar包就是RecyclerView要使用的,可以给它改个名字例如android-support-v7-recyclerview.jar

, 便于查看。

辛辛苦苦将jar包导进去,结果又把报错了

05-2920:27:51.665: E/AndroidRuntime(27611): java.lang.NullPointerException

05-2920:27:51.665: E/AndroidRuntime(27611): at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.support.v4.widget.SwipeRefreshLayout.onMeasure(SwipeRefreshLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.RelativeLayout.onMeasure(RelativeLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.FrameLayout.onMeasure(FrameLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureVertical(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.onMeasure(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureVertical(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.onMeasure(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.FrameLayout.onMeasure(FrameLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.FrameLayout.onMeasure(FrameLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureVertical(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.onMeasure(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.FrameLayout.onMeasure(FrameLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.measureVertical(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.LinearLayout.onMeasure(LinearLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.widget.FrameLayout.onMeasure(FrameLayout.

05-2920:27:51.665: E/AndroidRuntime(27611): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.View.measure(View.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.Choreographer$CallbackRecord.run(Choreographer.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.Choreographer.doCallbacks(Choreographer.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.Choreographer.doFrame(Choreographer.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.os.Handler.handleCallback(Handler.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.os.Handler.dispatchMessage(Handler.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.os.Looper.loop(Looper.

05-2920:27:51.665: E/AndroidRuntime(27611): at android.app.ActivityThread.main(ActivityThread.

05-2920:27:51.665: E/AndroidRuntime(27611): at

05-2920:27:51.665: E/AndroidRuntime(27611): at

05-2920:27:51.665: E/AndroidRuntime(27611): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.

05-2920:27:51.665: E/AndroidRuntime(27611): at com.android.internal.os.ZygoteInit.main(ZygoteInit.

05-2920:27:51.665: E/AndroidRuntime(27611): at dalvik.system.NativeStart.main(Native Meth 解决办法:

RecyclerView在onCreate的时候,要确定尺寸,需要执行:

RecyclerView.setLayoutManager(new LinearLayoutManager(mContext));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值