ButterKnife java.lang.ClassCastException: android.view.View cannot be cast to android.app.Activity
来源:互联网 发布:旧电脑安装linux 编辑:程序博客网 时间:2024/05/16 08:49
今天使用ButterKnife报以下错误:
Caused by: java.lang.ClassCastException: android.view.View cannot be cast to android.app.Activity at butterknife.internal.Finder$2.getContext(Finder.java:35) at butterknife.internal.Finder.getResourceEntryName(Finder.java:111) at butterknife.internal.Finder.castView(Finder.java:82) at hibaby.expert.course.live.LiveActivity_ViewBinding.<init>(LiveActivity_ViewBinding.java:32) at hibaby.expert.course.live.LiveActivity_ViewBinder.bind(LiveActivity_ViewBinder.java:13) at hibaby.expert.course.live.LiveActivity_ViewBinder.bind(LiveActivity_ViewBinder.java:10) at butterknife.ButterKnife.bind(ButterKnife.java:125) at hibaby.expert.course.live.LiveActivity.onCreate(LiveActivity.java:67) at android.app.Activity.performCreate(Activity.java:6161) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
经过检查,发现,并非是ButterKnife.bind(Activity)错误,而是声明的对象中,有一个View类型的视图,被声明成了TextView而导致的错误。ButterKnife不能正确打印此错误,不知道算不算他们的BUG。
//更正前 @BindView(R.id.v_left) TextView tvLeft; //更正后 @BindView(R.id.v_left) View tvLeft;
OK,问题解决。
0 0
- ButterKnife java.lang.ClassCastException: android.view.View cannot be cast to android.app.Activity
- Android java.lang.ClassCastException: android.view.View cannot be cast to android.view.ViewGroup
- 异常:java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.view.
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.view.ViewGroup$MarginLayoutParams
- java.lang.ClassCastException: android.app.Application cannot be cast to *****
- java.lang.ClassCastException: android.app.Application cannot be cast to *****
- java.lang.ClassCastException: android.app.Application cannot be cast to
- java.lang.ClassCastException: android.app.Application cannot be cast to
- java.lang.ClassCastException: android.app.Application cannot be cast to
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L
- java.lang.ClassCastException: android.content.res.XmlBlock$Parser cannot be cast to android.view.ani
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.R
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.
- actionbar出现java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to 的解决办法
- android.view.ContextThemeWrapper cannot be cast to android.app.Activity
- java.lang.ClassCastException: android.app.Application cannot be cast
- java.lang.ClassCastException: android.app.Application cannot be cast to greendroid.app.MyApplication
- 从零开始写C# MVC框架之--- 主框架页
- 渐隐渐显轮播/fadeIn()/fadeOut()/左右点击轮播
- copypng emitted errors
- 面向对象——封装
- oracle 函数
- ButterKnife java.lang.ClassCastException: android.view.View cannot be cast to android.app.Activity
- Genymotion模拟器安装Genymotion-ARM-Translation变copy
- 【项目1-顺序表的基本运算】
- 第3周项目4-顺序表应用问题(2)
- DOM三大方法的区别
- Fragment中onOptionsItemSelected方法不起作用的解决方法
- 第3周项目3-求集合并集
- ORACLE 12C新特性——CDB与PDB
- hdu3715 Go Deeper--二分 & 2-sat