18、 Caused by: java.lang.NoSuchMethodException: [class android.content.Context..AttributeSet
錯誤日誌:
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class sourceforge.titlelan.VisualizerView
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:400)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1943)
at sourceforge.titlelan.MainActivity.onCreate(MainActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5052)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
at java.lang.Class.getConstructorOrMethod(Class.java:472)
at java.lang.Class.getConstructor(Class.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:571)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:400)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1943)
at sourceforge.titlelan.MainActivity.onCreate(MainActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5052)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
1、上面的VisualizerView是我自定義的控制元件,而控制元件只有下面一個構造方法而已
public VisualizerView(Context context) {
super(context);
init();
}
2、分析:
<init> [class android.content.Context, interface android.util.AttributeSet]
這裡明確說明在定義view時,沒有重寫含有(Context context,AttributeSet attrs)的構造器
3、解決方案:
在自定義View時,必須要重寫(Context context,AttributeSet attrs)構造方法
public VisualizerView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
相關文章
- 18-containers-Runtime ClassAI
- Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load classbootException
- python3 筆記18.構建類classPython筆記
- Caused by: android.os.Android
- nested exception is java.lang.NoSuchMethodException: 實體類.()ExceptionJava
- java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.ExampleProvider.「init」()JavaExceptionMyBatisAPPIDE
- java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addFilterJavaExceptionApacheWebXMLFilter
- Caused by: Error: ' ' is not a valid resource name characterError
- Caused by:.NoSuchBeanDefinitionException: No bean named 'userInfoServiceImpl' availableBeanExceptionAI
- Springboot:Caused by: java.lang.NoSuchMethodError...Spring BootJavaError
- Caused by: java.lang.NoClassDefFoundError: javax/servlet/GenericFilterJavaErrorServletFilter
- Caused by: java.lang.NumberFormatException: For input string: "18446744073709551615"JavaORMException
- iOS[super class]和[self class]iOS
- Caused by: java.lang.IllegalArgumentException: port out of range:-1JavaException
- class
- Typescript的interface、class和abstract classTypeScript
- E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packagesErrorPackage
- Caused by: java.lang.IllegalArgumentException: Unable to instantiate SparkSession with Hive supportJavaExceptionSparkSessionHive
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of typeSpringFrameworkBeanException
- self::class和static::class的區別
- 28、Static Nested Class 和 Inner Class的不同。
- Caused by: java.lang.IllegalStateException: getWriter() has already been called for this responseJavaException
- Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for clASTXMLException
- Caused by: com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.7.3ASTXMLJSONAPPException
- Class-map
- [Javascript] Class & PrototypesJavaScript
- JavaScript:類(class)JavaScript
- 007 Class(類)
- this與class(原型)原型
- dart class overviewDartView
- JavaScript class 類JavaScript
- Caused by: java.lang.IllegalStateException: Only single-level inheritance supported: XxxxServiceJavaException
- The addressing-1.5.mar module, which is not valid, caused null java.lang.ExceptionInInitializerErrorNullJavaExceptionError
- Caused by: org.apache.ibatis.binding.BindingException: Parameter 'parameter' not found.解決ApacheBATException
- Caused by: java.lang.ClassNotFoundException: javax.management.j2ee.statistics.StatsJavaException
- PhysicalProduct Advanced class design
- React — Class類元件React元件
- Class檔案解析
- TypeScript 編譯 classTypeScript編譯