Android常见错误汇编
来源:互联网 发布:淘宝天下小二 培训 编辑:程序博客网 时间:2024/04/30 00:01
Android常见错误汇编
目标
该文档主要用于收集,归纳和整理日常Android开发中经常碰到的错误。包括编译错误,运行性错误,非运行性错误和ANR。目前整理不全,以后会在不断开发中逐步完善该篇文档。
一、编译错误
二、运行时错误
1. android.app.Fragment$InstantiationException报错
1)根据报错提示“make sure class name exists, is public, and has an empty constructor that is public”,若Fragement定义有带参构造函数,则一定要定义public的默认的构造函数。即可解决此问题。如果硬要携带参数进去,可以通过Intent结合Bunble的方式携带进去。
2)在“is public, and has an empty constructor that is public” 都满足的情况下,编译ENG版本运行没有任何问题,但是编译USER版本就会出现CRASH错误。报错log信息如下:
E/AndroidRuntime( 3253): FATAL EXCEPTION: mainE/AndroidRuntime( 3253): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.SubSettings}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.settings.mcwill.McWiLLSettings: make sure class name exists, is public, and has an empty constructor that is publicE/AndroidRuntime( 3253): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1964)E/AndroidRuntime( 3253): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1989)E/AndroidRuntime( 3253): at android.app.ActivityThread.access$600(ActivityThread.java:126)E/AndroidRuntime( 3253): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1155)E/AndroidRuntime( 3253): at android.os.Handler.dispatchMessage(Handler.java:99)E/AndroidRuntime( 3253): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 3253): at android.app.ActivityThread.main(ActivityThread.java:4482)E/AndroidRuntime( 3253): at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntime( 3253): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 3253): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)E/AndroidRuntime( 3253): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)E/AndroidRuntime( 3253): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 3253): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.settings.mcwill.McWiLLSettings: make sure class name exists, is public, and has an empty constructor that is publicE/AndroidRuntime( 3253): at android.app.Fragment.instantiate(Fragment.java:581)E/AndroidRuntime( 3253): at android.preference.PreferenceActivity.switchToHeaderInner(PreferenceActivity.java:1120)E/AndroidRuntime( 3253): at android.preference.PreferenceActivity.switchToHeader(PreferenceActivity.java:1136)E/AndroidRuntime( 3253): at android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:532)E/AndroidRuntime( 3253): at com.android.settings.Settings.onCreate(Settings.java:99)E/AndroidRuntime( 3253): at android.app.Activity.performCreate(Activity.java:4465)E/AndroidRuntime( 3253): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)E/AndroidRuntime( 3253): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)E/AndroidRuntime( 3253): ... 11 more E/AndroidRuntime( 3253): Caused by: java.lang.ClassNotFoundException: com.android.settings.mcwill.McWiLLSettingsE/AndroidRuntime( 3253): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)E/AndroidRuntime( 3253): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)E/AndroidRuntime( 3253): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)E/AndroidRuntime( 3253): at android.app.Fragment.instantiate(Fragment.java:571)E/AndroidRuntime( 3253): ... 18 more W/ActivityManager( 422): Force finishing activity com.android.settings/.SubSettingsW/ActivityManager( 422): Force finishing activity com.android.settings/.Settings
该类错误原因在于USER版本编译时会代码混淆。解决办法:
在对应模块的proguard.flags文件中引入该Fragment所在的类包即可。比如:
-keep class com.android.settings.wifi.*Settings
三、非运行时错误
四、ANR(Application Not Responding)
- Android常见错误汇编
- 汇编常见错误
- 汇编常见错误
- 汇编常见错误
- 汇编中常见的错误
- 【常见错误】android常见错误
- 常见汇编编译错误中英文对照
- 汇编中常见的错误2
- 汇编常见错误----合集(转)
- Android 常见错误
- android应用常见错误
- Android常见错误
- Android 常见错误
- Android常见错误
- Android常见错误
- android常见错误
- Android常见错误
- Android常见错误
- 我的求职经历:走进过腾讯、网易、百度、迅雷
- spice图像压缩简介
- 异步 HttpContext.Current实现取值的方法(解决异步Application,Session,Cache...等失效的问题)
- Android在Activity中取消EditText自动获取焦点的默认行为
- 清宫图 生男生女java 算法 c算法
- Android常见错误汇编
- Access数据库表与SQL数据库表以命令方式相互导入导出
- SAP BI:SSIS实现对SAP数据的抽取
- 计算机是如何启动的?
- 38头牛中选出3头跑得最快的,使用一个每次只能供6头比赛的场地,要求用最快的方法。
- C++二进制字符串变成十进制整型代码
- 易信推公众平台,今起开始公测
- ADO 与ADO.NET两种数据访问方式区别。
- 页面跳转的几种方式