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
随机推荐
- Eclipse 4.5插件安装以及其他设置
eclipse安装Veloeclipse.ui_2.0.8 在help-> install new software ->workwith中输入The Eclipse Project ...
- JVM入门——JVM内存结构
一.java代码编译执行过程 1.源码编译:通过Java源码编译器将Java代码编译成JVM字节码(.class文件) 2.类加载:通过ClassLoader及其子类来完成JVM的类加载 3.类执行: ...
- 安装配置convirture
Author: Jin Date: 20130627 Title: 安装配置convirture 参考: http://www.convirture.com/wiki/index.php?title= ...
- VirtualBox的网络配置,Host Only+NAT方式
其实网络这类相关的文章很多,我只是想结合自己的实际情况,把我的经验写下来,给那些需要的人们吧. 主机:windows xp 虚拟机:ubuntu 10.10 Virtualbox:4.0.2 虚拟机在 ...
- Java8新语言特性
Java8简明指南 欢迎来到Java8简明指南.本教程将一步一步指导你通过所有新语言特性.由短而简单的代码示例,带你了解如何使用默认接口方法,lambda表达式,方法引用和可重复注解.本文的最后你会熟 ...
- JAVA常见算法题(二十八)
package com.forezp.util; import java.util.Arrays; /** * 两个int数组,都是从小到大的的排列,请合并为一个新的数组,也是从小到到大的排列, * ...
- Kubernetes下的应用监控解决方案
所谓应用监控,更多的是基于java jvm的监控,因为公司运行的中间件大部分都是基于tomcat,Springboot,SpringCloud,当然也必须支持WebLogic.在Kubernetes现 ...
- zabbix3.2 报错 Database error
一.Database errorThe frontend does not match Zabbix database. Current database version (mandatory/opt ...
- TestNG 七 annotation
TestNG中用到的annotation的快速预览及其属性. @BeforeSuite: 被注释的方法将在所有测试运行前运行 @AfterSuite: 被注释的方法将在所有测试运行后运行 @Be ...
- sonatype Nexus3 install on Kubernetes
Nexus 搭建代码 apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nexus3 labels: app: nexus ...