Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet] 异常
1. 异常描述
FATAL EXCEPTION: main
Process: com.whereru.greengrass.goforit, PID: 13847
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whereru.greengrass.goforit/com.whereru.greengrass.goforit.activity.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.whereru.greengrass.goforit.ui.BaseViewPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2457)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
at android.app.ActivityThread.access$1200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5669)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.whereru.greengrass.goforit.ui.BaseViewPager
at android.view.LayoutInflater.createView(LayoutInflater.java:635)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:825)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:935)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:523)
at android.view.LayoutInflater.inflate(LayoutInflater.java:425)
at android.view.LayoutInflater.inflate(LayoutInflater.java:368)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:380)
at android.app.Activity.setContentView(Activity.java:2188)
at com.whereru.greengrass.goforit.activity.MainActivity.onCreate(MainActivity.java:24)
at android.app.Activity.performCreate(Activity.java:6102)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2410)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
at android.app.ActivityThread.access$1200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5669)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
at java.lang.Class.getConstructor(Class.java:531)
at java.lang.Class.getConstructor(Class.java:495)
at android.view.LayoutInflater.createView(LayoutInflater.java:599)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:825)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:935)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:523)
at android.view.LayoutInflater.inflate(LayoutInflater.java:425)
at android.view.LayoutInflater.inflate(LayoutInflater.java:368)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:380)
at android.app.Activity.setContentView(Activity.java:2188)
at com.whereru.greengrass.goforit.activity.MainActivity.onCreate(MainActivity.java:24)
at android.app.Activity.performCreate(Activity.java:6102)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2410)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
at android.app.ActivityThread.access$1200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5669)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
2. 自定义View时,要同时覆写
public XXXX(Context context) {
super(context);
} /**
* 自定义View时,如果自定义View有属性,这个方法一定要覆写!!
*
* @param context
* @param attrs
*/
public XXXX(Context context, AttributeSet attrs) {
super(context, attrs);
}
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet] 异常的更多相关文章
- Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android
在写自己定义的view时,有时会报下面错误: Caused by: java.lang.NoSuchMethodException: <init> [class android.co ...
- Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on a null object reference
/********************************************************************************* * Caused by: java ...
- Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties;
报错信息 Error starting ApplicationContext. To display the auto-configuration report re-run your applica ...
- 【报错】spring整合activeMQ,pom.xml文件缺架包,启动报错:Caused by: java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
spring版本:4.3.13 ActiveMq版本:5.15 ======================================================== spring整合act ...
- java.lang.NoSuchMethodException: .<init>()
严重: Servlet.service() for servlet [springmvc] in context with path [/SpringMvc-1] threw exception [R ...
- spring报错 :java.lang.NoSuchMethodException: <init>()
Spring要求init-method是一个无参数的方法,如果init-method指定的方法中有参数,那么Spring将会抛出java.lang.NoSuchMethodException ...
- java.lang.NoSuchMethodException: <init> [class android.content.Context, interface androidutil.Attri
<pre name="code" class="java"><span style="font-size:24px;"&g ...
- mybatis Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class .. with invalid types () or values (). Cause: java.lang.NoSuchMethodException: ...<init>()
如果有带参数的构造器,编译器不会自动生成无参构造器.当查询需要返回对象时,ORM框架用反射来调用对象的无参构造函数,所以会导致此类异常 public Test(){ }
- Caused by: java.lang.NullPointerException: Attempt to write to field 'int android.app.Fragment.mNextAnim' on a null object reference
原因fragment必须先add(),才能remove(),故remove前先做判空操作 参考:http://www.cnblogs.com/hixin/p/4427276.html
随机推荐
- JVM堆 栈 方法区详解
一.栈 每当启用一个线程时,JVM就为他分配一个JAVA栈,栈是以帧为单位保存当前线程的运行状态 栈是由栈帧组成,每当线程调用一个java方法时,JVM就会在该线程对应的栈中压入一个帧 只有在调用一个 ...
- Redis 真得那么好用吗?
不管你是从事Python.Java.Go.PHP.Ruby等等......Redis都应该是一个比较熟悉的中间件.而大部分经常写业务代码的程序员,实际工作中或许只用到了set value.GetVal ...
- sql server 博客:不胜人生一场醉
http://blog.csdn.net/baoqiangwang/article/category/604358
- ajax跨域的解决方案
前言 公司要做一个活动页面,在其过程中发现所有的接口,ajax请求跨域.这里对跨域做个简单介绍以及提供几种解决办法. 由于浏览器实现的同源策略的限制,XmlHttpRequest只允许请求当前源(域名 ...
- 轻量级web服务器lighttpd的编译及配置(for x86-linux)
转自:http://blog.163.com/ljf_gzhu/blog/static/131553440201211522317367/ 备注: PC Linux:Ubuntu-10.10 Linu ...
- unity3d的矩阵元素存储方式
想知道u3d矩阵各个元素的存储方式,所以测试了一下 Matrix4x4 m = Matrix4x4.TRS(new Vector3(1, 2, 3), Quaternion.Euler(0, 0, 3 ...
- XML-RPC 实现C++和C#交互
我们通常会面对这样的问题:整合不同平台或不同类库,这些类库可能来自不同的语言,甚至不同的操作系统. 如何解决这类棘手的问题呢? 一.方案介绍 解决不同语言交互的方法有不少,对我了解的windows系统 ...
- IP地址转换、主机大小端、htonl、ntohl实现
copy #include <IOSTREAM> //#include <WINSOCK.H> using std; typedef uint16; unsigned ...
- 页面优化——js异步载入
同步载入 在介绍js异步载入之前.我们先来看看什么是js同步载入.我们平时最常使用的就是这样的同步载入形式: <script src="http://XXX.com/script.js ...
- Leetcode--easy系列5
#83 Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such that e ...