运行类错误分析

运行类错误大致包括:



# [[NDK运行时错误:非法内存地址]]
# [[NDK运行时错误:空指针]]
# [[NDK运行时错误:试图使用已经释放的内存地址]]
# [[java.lang.NullPointerException]]
# [[ANR]]
# [[java.lang.UnsatisfiedLinkError]]
# [[android.view.WindowManager$BadTokenException]]
# [[java.lang.NoSuchMethodError]]
# [[java.lang.IllegalStateException]]
# [[java.lang.UnsupportedOperationException]]
# [[java.lang.ClassNotFoundException]]
# [[java.lang.NoClassDefFoundError]]
# [[android.content.ActivityNotFoundException]]
# [[java.lang.OutOfMemoryError]]
# [[java.lang.NoSuchFieldError]]
# [[NDK运行时错误:堆栈错误或者访问越界]]
# [[java.lang.StringIndexOutOfBoundsException]]
# [[android.content.res.Resources$NotFoundException]]
# [[android.database.sqlite.SQLiteException]]
# [[java.lang.IndexOutOfBoundsException]]
# [[java.lang.IllegalThreadStateException]]
# [[java.lang.SecurityException]]
# [[android.database.sqlite.SQLiteCantOpenDatabaseException]]
# [[java.lang.NumberFormatException]]
# [[java.lang.ClassCastException]]
# [[java.lang.ArrayIndexOutOfBoundsException]]
# [[libcore.io.ErrnoException]]
# [[java.lang.VerifyError]]
# [[android.database.sqlite.SQLiteDiskIOException]]
# [[com.badlogic.gdx.utils.GdxRuntimeException]]
# [[java.lang.StackOverflowError]]
# [[java.lang.ArithmeticException]]
# [[java.lang.CloneNotSupportedException]]
# [[java.io.FileNotFoundException]]
# [[com.test.video.UnsupportVideoFormatException]]
# [[java.io.IOException]]
# [[android.view.ViewRootImpl$CalledFromWrongThreadException]]
# [[android.database.CursorIndexOutOfBoundsException]]
# [[java.util.ConcurrentModificationException]]
# [[android.app.SuperNotCalledException]]
# [[java.lang.Error]]
# [[android.os.NetworkOnMainThreadException]]
# [[java.lang.IncompatibleClassChangeError]]
# [[java.lang.NoSuchMethodException]]
# [[java.lang.NegativeArraySizeException]]
# [[android.database.sqlite.SQLiteDatabaseCorruptException]]
# [[android.util.AndroidRuntimeException]]
# [[junit.framework.AssertionFailedError]]
# [[net.sqlcipher.database.SQLiteException]]
# [[java.nio.BufferOverflowException]]
# [[android.os.DeadObjectException]]
# [[android.database.sqlite.SQLiteDatabaseLockedException]]
# [[java.util.concurrent.RejectedExecutionException]]
# [[com.google.gson.JsonParseException]]
# [[java.io.FileNotFoundException]]
# [[org.xmlpull.v1.XmlPullParserException]]
# [[android.view.ViewRoot$CalledFromWrongThreadException]]
# [[java.util.NoSuchElementException]]
# [[android.os.RemoteException]]
# [[java.lang.InstantiationException]]
# [[android.app.RemoteServiceException]]
# [[android.view.InflateException]]
# [[android.support.v8.renderscript.RSRuntimeException]]
# [[com.kascend.NetworkKernel.api.except.TaskNotValidException]]
# [[java.lang.Exception]]
# [[com.google.android.vending.licensing.util.Base64DecoderException]]
# [[android.database.sqlite.SQLiteFullException]]
# [[java.lang.reflect.InvocationTargetException]]
# [[android.database.sqlite.SQLiteMisuseException]]
# [[android.os.TransactionTooLargeException]]
# [[java.net.SocketException]]
# [[java.net.SocketTimeoutException]]
# [[com.alibaba.fastjson.JSONException]]
# [[java.net.UnknownHostException]]
# [[java.lang.ArrayStoreException]]
# [[com.sqlcrypt.database.sqlite.SQLiteDatabaseLockedException]]
# [[android.os.BadParcelableException]]
# [[java.lang.IllegalAccessException]]
# [[android.database.StaleDataException]]
#[[com.soundhound.serviceapi.marshall.ResponseParser$ResponseParserException]]
# [[android.database.CursorWindowAllocationException]]
# [[java.lang.AbstractMethodError]]
# [[java.io.NotSerializableException]]
# [[android.net.ParseException]]
# [[com.google.gson.stream.MalformedJsonException]]
# [[java.lang.InstantiationError]]
# [[java.lang.IllegalAccessError]]
# [java.security.cert.CertificateNotYetValidException|java.security.cert.CertificateNotYetValidException]]
# [[com.yq.pay.exception.PayException]]
# [[org.andengine.util.exception.NullBitmapException]]
# [[java.lang.AssertionError]]
# [[java.lang.IllegalMonitorStateException]]
# [[com.scoreloop.client.android.ui.manager.Checker$CheckerException]]
# [[java.util.MissingResourceException]]
# [[java.util.concurrent.TimeoutException]]
# [[java.net.MalformedURLException]]
# [[org.andengine.audio.sound.exception.SoundReleasedException]]
# [[com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException]]
# [[android.os.ParcelFormatException]]
# [[java.util.zip.DataFormatException]]
# [[org.andengine.audio.music.exception.MusicReleasedException]]


1) ANR

官方描述:全称为Application Not Responding。当某个应用处于长期假死状态时Android系统会发出此异常。

分析可能触发ANR的情况:

1.长时间的I/O处理,比如读写大文件,网络访问时造成的阻塞。
2.执行耗时的运算,Android默认为超过5000ms即5秒开始弹出ANR窗口,某些应用可能首次执行时没有缓存十分耗时,可以通过Splash播放闪屏Logo等方式来延缓加载。
3.Service和appWidget中也要注意多线程的使用,除非它和Activity工作在不同的进程。

4.monkey 测试时,命令发的太多太快。


Testin测试日志示例


12-1219:37:25.140E/ActivityManager(257):ANR in com.xxx.xxx(com.xxx.xxx/com.xxx.ui.activity.xxxActivity)
12-1219:37:25.140E/ActivityManager(257):Reason:keyDispatchingTimedOut
12-1219:37:25.140E/ActivityManager(257):Load:12.7/6.78/4.17
.......



解决建议

1.单独开工作者线程,通过独立的Thread或使用类似AsyncTask的方式来处理耗时的内容。
2.耗时的操作尽量分段处理,使用类似状态机的方法,类似Symbian的活动对象将一个复杂的事情,分段执行。
3.UI线程中不要处理过多的内容,比如将一个5MB的文本,让TextView去setText,要知道这种UI操作,没有什么好方法去解决的,所以遇到UI中需要执行复杂的操作,可以参考上面2提到的分段处理方式。

4.monkey操作之间间隔一段时间。


2)NDK运行时错误:堆栈错误或者访问越界

官方描述:略
分析:一般是由于当调用c/c++程序的so库文件时,发生的错误。
Testin测试日志示例



12-12 19:34:50.246I/DEBUG(1953):signal 16(SIGSTKFLT),code-6(?),fault addr--------
12-12 19:34:50.386I/DEBUG(1953):r0 400cbba4 r1 00000080 r2 2e734002 r3 00000000
12-12 19:34:50.386I/DEBUG(1953):r4 400cbba4 r5 00000000 r6 00004000 r7 000000f0
12-12 19:34:50.386I/DEBUG(1953):r8 4009cc71 r9 1d900011 sl 40015bf8 fp 5d7a0c6c
12-12 19:34:50.386I/DEBUG(1953):ip 00000000 sp 5d7a0980 lr 40094208 pc 4008fca0
cpsr 60000010
12-12 19:34:50.386I/DEBUG(1953):d0 4040000040000000 d1 3ff0000043a04000
12-12 19:34:50.386I/DEBUG(1953):d2 0000000043b98000 d3 3f00000000000000
12-12 19:34:50.386I/DEBUG(1953):d4 0000000000000000 d5 3f00000000000000
12-12 19:34:50.386I/DEBUG(1953):d6 000000003f3f7651 d7 400000003f800000
12-12 19:34:50.386I/DEBUG(1953):d8 0000000000000000 d9 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d10 0000000000000000 d11 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d12 0000000000000000 d13 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d14 0000000000000000 d15 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d16 0000000000000001 d17 4010000000000000
12-12 19:34:50.386I/DEBUG(1953):d18 405dc00000000000 d19 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d20 0000000000000000 d21 3fe7eeca2c449f9d
12-12 19:34:50.386I/DEBUG(1953):d22 8000000000000000 d23 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d24 0000000000000000 d25 8000000000000000
12-12 19:34:50.386I/DEBUG(1953):d26 3fe7fa7ad156ab84 d27 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d28 0000000000000005 d29 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):d30 0000000000000000 d31 0000000000000000
12-12 19:34:50.386I/DEBUG(1953):scr 60000010
12-12 19:34:50.396I/DEBUG(1953):

12-12 19:34:50.396I/DEBUG(1953):backtrace:
12-12 19:34:50.396I/DEBUG(1953):#00 pc 0000dca0 /system/lib/libc.so(__futex_syscall3+8)
12-12 19:34:50.396I/DEBUG(1953):#01 pc 00012204 /system/lib/libc.so
12-12 19:34:50.396I/DEBUG(1953):#02 pc 0001ac7f /system/lib/libc.so(__sflush_locked+14)
12-12 19:34:50.396I/DEBUG(1953):#03 pc 0001bc63 /system/lib/libc.so(_fwalk+30)
12-12 19:34:50.396I/DEBUG(1953):#04 pc 00045eeb /system/lib/libdvm.so(dvmAbort+102)
12-12 19:34:50.396I/DEBUG(1953):#05 pc 0004a01f /system/lib/libdvm.so(dvmDecodeIndirectRef(Thread*,_jobject*)+210)
12-12 19:34:50.396I/DEBUG(1953):#06 pc 0004ad0d /system/lib/libdvm.so
12-12 19:34:50.396I/DEBUG(1953):#07 pc 0001eaf9 /data/data/com.youku.phone/lib/libmresearch.so(getEncrptPassword+116)
12-12 19:34:50.396I/DEBUG(1953):#08 pc 0001ed19 /data/data/com.youku.phone/lib/libmresearch.so(Java_cn_com_iresearch_mapptracker_util_DataProvider_getDesP+196)
12-12 19:34:50.396I/DEBUG(1953):#09 pc 0001df30 /system/lib/libdvm.so(dvmPlatformInvoke+112)
12-12 19:34:50.396I/DEBUG(1953):#10 pc 0004d183 /system/lib/libdvm.so(dvmCallJNIMethod(unsignedintconst*,JValue*,Methodconst*,Thread*)+394)
12-12 19:34:50.396I/DEBUG(1953):#11 pc 0004f29f /system/lib/libdvm.so(dvmResolveNativeMethod(unsignedintconst*,JValue*,Methodconst*,Thread*)+174)
12-12 19:34:50.396I/DEBUG(1953):#12 pc 00027360 /system/lib/libdvm.so
12-12 19:34:50.396I/DEBUG(1953):#13 pc 0002bc68 /system/lib/libdvm.so(dvmInterpret(Thread*,Methodconst*,JValue*)+180)
12-12 19:34:50.396I/DEBUG(1953):#14 pc 0005f8f1 /system/lib/libdvm.so(dvmCallMethodV(Thread*,Methodconst*,Object*,bool,JValue*,std::__va_list)+272)
12-12 19:34:50.396I/DEBUG(1953):#15 pc 0005f91b /system/lib/libdvm.so(dvmCallMethod(Thread*,Methodconst*,Object*,JValue*,...)+20)
12-12 19:34:50.396I/DEBUG(1953):#16 pc 000544d3 /system/lib/libdvm.so
12-12 19:34:50.396I/DEBUG(1953):#17 pc 00012e00 /system/lib/libc.so(__thread_entry+48)
12-12 19:34:50.396I/DEBUG(1953):#18 pc 00012558 /system/lib/libc.so(pthread_create+172)
12-12 19:34:50.396I/DEBUG(1953):
解决建议:根据log,backtrace定位解决错误。




3)NDK运行时错误:非法内存地址

官方描述:略
分析:一般是由于当调用c/c++程序的so库文件时,发生的内存地址错误。
Testin测试日志示例



12-12 19:35:15.161 I/DEBUG(10035):signal 11(SIGSEGV),code1(SEGV_MAPERR),fault addr 00000010
12-12 19:35:15.177 V/ActivityManager(476):getTasks:max=1,flags=0,receiver=null
12-12 19:35:15.177 V/ActivityManager(476):com.xxx.xxx/.ActivityWelcome:task=TaskRecord{423c0728#91Acom.youku.phoneU0}
12-12 19:35:15.177 V/ActivityManager(476):Wehavependingthumbnails:null
12-12 19:35:15.238 I/DEBUG(10035):r0 00000000 r1 00000007 r2 4f9e2440 r3 4efb2f10
12-12 19:35:15.238 I/DEBUG(10035):r4 4f9e2440 r5 41fee9a0 r6 00000010 r7 4efb2f20
12-12 19:35:15.238 I/DEBUG(10035):r8 1d500005 r9 1d900011 sl 4efb2f20 fp 52401c64
12-12 19:35:15.238 I/DEBUG(10035):ip 40048f9c sp 52401c00 lr 40af5d39 pc 52420b0c cpsr 80000030
12-12 19:35:15.240 I/DEBUG(10035):
12-12 19:35:15.240 I/DEBUG(10035):backtrace:
12-12 19:35:15.240 I/DEBUG(10035):#00 pc 0001eb0c /data/data/com.youku.phone/lib/libmresearch.so(getEncrptPassword+135)
12-12 19:35:15.240 I/DEBUG(10035):#01 pc 0001ed19 /data/data/com.youku.phone/lib/libmresearch.so(Java_cn_com_iresearch_mapptracker_util_DataProvider_getDesP+196)
12-12 19:35:15.240 I/DEBUG(10035):#02 pc 0001e170 /system/lib/libdvm.so(dvmPlatformInvoke+112)
12-12 19:35:15.240 I/DEBUG(10035):#03 pc 0004d255 /system/lib/libdvm.so(dvmCallJNIMethod(unsignedintconst*,JValue*,Methodconst*,Thread*)+492)
12-12 19:35:15.240 I/DEBUG(10035):#04 pc 0004f487 /system/lib/libdvm.so(dvmResolveNativeMethod(unsignedintconst*,JValue*,Methodconst*,Thread*)+174)
12-12 19:35:15.240 I/DEBUG(10035):#05 pc 000275a0 /system/lib/libdvm.so
12-12 19:35:15.240 I/DEBUG(10035):#06 pc 0002b5d4 /system/lib/libdvm.so(dvmInterpret(Thread*,Methodconst*,JValue*)+176)
12-12 19:35:15.240 I/DEBUG(10035):#07 pc 00060299 /system/lib/libdvm.so(dvmCallMethodV(Thread*,Methodconst*,Object*,bool,JValue*,std::__va_list)+272)
12-12 19:35:15.240 I/DEBUG(10035):#08 pc 000602c3 /system/lib/libdvm.so(dvmCallMethod(Thread*,Methodconst*,Object*,JValue*,...)+20)
12-12 19:35:15.240 I/DEBUG(10035):#09 pc 00054b0d /system/lib/libdvm.so
12-12 19:35:15.240 I/DEBUG(10035):#10 pc 00012c0c /system/lib/libc.so(__thread_entry+48)
解决建议:根据log,backtrace定位错误。




4)NDK运行时错误:空指针

官方描述:略
分析:一般是由于当调用c/c++程序的so库文件时,当其内存地址为空时对其操作所产生的错误。
Testin测试日志示例



2013-12-12 19:38:53 运行错误: NDK error: fault addr 00000000   
12-12 19:38:53.085 F/libc(20938):Fatal signal 11(SIGSEGV) at 0x00000000(code=1)
12-12 19:38:53.085 I/DEBUG(7252):handle_crashing_process(8)
12-12 19:38:53.085 I/DEBUG(7252):reading tid
12-12 19:38:53.085 I/DEBUG(7252):BOOM:pid=20938uid=10179gid=10179tid=21153
12-12 19:38:53.085 I/DEBUG(7252):notreadyyet
12-12 19:38:53.285 I/DEBUG(7252):wait pid:n=21153status=0000137f
12-12 19:38:53.285 I/DEBUG(7252):stopped--continuing
12-12 19:38:53.285 I/DEBUG(7252):not ready yet
12-12 19:38:53.375 E/ANM(2038):[ERR]anm_ap:2849threadSubscribeModemStatus():FailedtoconnecttoADM
12-12 19:38:53.375 I//system/bin/mediaserver(2037):ERRste_adm_client_connect:Toomanyattemptstoconnectfailed!
12-12 19:38:53.485 I/DEBUG(7252):wait pid:n=21153status=00000b7f
12-12 19:38:53.485 I/DEBUG(7252):stopped--fatalsignal
12-12 19:38:53.505 I/DEBUG(7252):debuggerd:2013-12-1219:38:53
12-12 19:38:53.505 I/DEBUG(7252):************************************************
12-12 19:38:53.505 I/DEBUG(7252):Buildfingerprint:'htccn_chs_cu/cp2dug/cp2dug:4.0.4/IMM76D/130245.11:user/release-keys'
12-12 19:38:53.505 I/DEBUG(7252):pid:20938,tid:21153>>>com.xxx.xxx<<<
12-12 19:38:53.505 I/DEBUG(7252):debuggerd:checkTellHTCSettings
12-12 19:38:53.525 I/DEBUG(7252):signal 11(SIGSEGV),code1(SEGV_MAPERR),fault addr 00000000
......
解决建议:检查初始化分配内存,释放等操作。




5)NDK运行时错误:试图使用已经释放的内存地址

官方描述:略
分析:一般是由于当调用c/c++程序的so库文件时,发生对已释放的内存再次访问所产生的错误。
Testin测试日志示例



01-20 15:13:32.300 I/DEBUG(10143):pid:10496,tid:10496>>>com.xxx.xxx<<<
01-20 15:13:32.300 I/DEBUG(10143):signal 11(SIGSEGV),code 1(SEGV_MAPERR),fault addr deadbaad
01-20 15:13:32.300 I/DEBUG(10143):r0 00000027 r1 deadbaad r2 a0000000 r3 00000000
01-20 15:13:32.300 I/DEBUG(10143):r4 00000001 r5 00000000 r6 46d5e618 r7 0000b000
01-20 15:13:32.300 I/DEBUG(10143):r8 00000000 r9 bec7a198 10 bec7a170 fp 000001e0
01-20 15:13:32.300 I/DEBUG(10143):ip afd46668 sp bec79e38 lr afd192e9 pc afd15db8cpsr60800030
01-20 15:13:32.300 I/DEBUG(10143):d0 00000000ffd5e4ed d106f905d3063c067b
01-20 15:13:32.300 I/DEBUG(10143):d2 000002cf000002ce d30009000900090009
01-20 15:13:32.300 I/DEBUG(10143):d4 ff00d500e400ed00 d50007000700070007
01-20 15:13:32.300 I/DEBUG(10143):d6 08f7077d08040855 d708f7077d08040855
01-20 15:13:32.300 I/DEBUG(10143):d8 000001e100000000 d94680000000000026
01-20 15:13:32.300 I/DEBUG(10143):d1 00000000042940000 d11 0000000000000000
01-20 15:13:32.300 I/DEBUG(10143):d1 20000000000000000 d13 0000000000000000
01-20 15:13:32.300 I/DEBUG(10143):d1 40000000000000000 d15 0000000000000000
01-20 15:13:32.300 I/DEBUG(10143):d1 60010001000100010 d17 002d8c0f002d7387
01-20 15:13:32.300 I/DEBUG(10143):d1 800b3c02d00b3802d d19 00b4802d00b4402d
01-20 15:13:32.300 I/DEBUG(10143):d2 00000002d0000002d d21 0000002d0000002d
01-20 15:13:32.300 I/DEBUG(10143):d2 20000000000000000 d23 0000000000000000
01-20 15:13:32.300 I/DEBUG(10143):d2 40000002d0000002d d25 0000002d0000002d
01-20 15:13:32.300 I/DEBUG(10143):d2 60000002c0000002c d27 0000002d0000002d
01-20 15:13:32.300 I/DEBUG(10143):d2 80000622000006220 d29 0000622000006220
01-20 15:13:32.300 I/DEBUG(10143):d3 00001000000010000 d31 0001000000010000
01-20 15:13:32.300 I/DEBUG(10143):scr 20000012
01-20 15:13:32.300 I/DEBUG(10143):
解决建议:根据log,backtrace定位错误,分析是否要重新分配内存或之前不要释放等。




6)Android.content.ActivityNotFoundException

官方描述:当调用startActivity(intent)或它的其中一个变体失败时抛出此异常,因为窗体不能找到执行intent
分析:略
Testin测试日志示例



01-21 16:05:00.449: E/AndroidRuntime(32441): FATAL EXCEPTION: main
01-21 16:05:00.449: E/AndroidRuntime(32441): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.itesterror/com.example.itesterror.second}; have you declared this activity in your AndroidManifest.xml?
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1568)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1438)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.Activity.startActivityForResult(Activity.java:3388)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.Activity.startActivityForResult(Activity.java:3349)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.Activity.startActivity(Activity.java:3559)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.Activity.startActivity(Activity.java:3527)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at com.example.itesterror.MainActivity$1.onClick(MainActivity.java:27)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.view.View.performClick(View.java:4084)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.view.View$PerformClick.run(View.java:16987)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.os.Handler.handleCallback(Handler.java:615)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.os.Looper.loop(Looper.java:137)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at android.app.ActivityThread.main(ActivityThread.java:4802)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at java.lang.reflect.Method.invoke(Method.java:511)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-21 16:05:00.449: E/AndroidRuntime(32441):     at dalvik.system.NativeStart.main(Native Method)
......
解决建议:AndroidMainfest.xml中是否声明新添加的Activity。




7)Android.content.res.Resources$NotFoundException

官方描述:当被请求的资源找不到时,由resource api抛出。
分析:略
Testin测试日志示例



10-10 14:09:57.878 E/AndroidRuntime(17175):FATAL EXCEPTION:Thread-79
10-10 14:09:57.878 E/AndroidRuntime(17175):android.content.res.Resources$Not Found Exception:String resource ID#0x7f0900f9
10-10 14:09:57.878 E/AndroidRuntime(17175):at android.content.res.Resources.getText(Resources.java:210)
10-10 14:09:57.878 E/AndroidRuntime(17175):at android.content.res.Resources.getString(Resources.java:263)
10-10 14:09:57.878 E/AndroidRuntime(17175):at android.content.Context.getString(Context.java:183)
10-10 14:09:57.878 E/AndroidRuntime(17175):at com.xxx.xxx.xxx.item.s.a(HealthWlanAutoUpdateLab.java:36)
10-10 14:09:57.878 E/AndroidRuntime(17175):at com.xxx.xxx.xxx.a.a.b(HealthManager.java:412)
10-10 14:09:57.878 E/AndroidRuntime(17175):at com.xxx.xxx.xxx.a.a.a(HealthManager.java:33)
10-10 14:09:57.878 E/AndroidRuntime(17175):at com.xxx.xxx.xxx.a.a$1.run(HealthManager.java:153)
10-10 14:09:57.878 E/AndroidRuntime(17175):at java.lang.Thread.run(Thread.java:1027)
......
解决建议:略




8)Android.database.CursorIndexOutOfBoundsException

官方描述:cursor越界
分析:略
Testin测试日志示例:略
解决建议:略


9)Android.database.sqlite.SQLiteCantOpenDatabaseException

官方描述:SQLite 打开数据库时异常。
分析:略
Testin测试日志示例:略
解决建议:卸载相应软件,开关机,重新安装该软件。


10)Android.database.sqlite.SQLiteDatabaseCorruptException

官方描述:SQLite数据库文件受损时抛出此异常
分析:略
Testin测试日志示例:略
解决建议:略


11)Android.database.sqlite.SQLiteDiskIOException

官方描述:访问SQLite 数据库文件时发生IO错误抛出的异常。
分析:略
Testin测试日志示例:略
解决建议:略


12) Android.database.sqlite.SQLiteException

官方描述:一个SQLite异常,表示SQL解析或执行有错误。
分析:略
Testin测试日志示例:



07-13 18:10:37.750 E/AndroidRuntime(22384):FATAL EXCEPTION:DefaultRestoringWaitingThread
07-13 18:10:37.750 E/AndroidRuntime(22384):android.database.sqlite.SQLiteException:no such table:t_category:,while compiling:select cate_name,pkgname from t_category inner join t_app on t_category.cate_p=t_app.cate_p where pkgname in("com.xxx.android.xxxx","com.xxx.android.xxx","com.android.music","com.xxx.android.contacts.dial","com.android.camera","com.xxx.android.savepowermanager","com.xxx.android.adscription","com.xxx.android.filebrowser","com.android.settings","com.xxx.android.softmanager","com.android.quicksearchbox","com.android.email","com.xxx.android.calendar","com.xxx.android.memo","com.xxx.android.xtime","com.broadcom.bt.app.fm","com.android.calculator2","com.xxx.android.soundrecorder","com.android.settings.wifi","com.android.gallery3d","com.xxx.android.backup","com.xxx.android.ota","com.xxx.android.contacts","com.xxx.android.callhistory","com.xxx.android.cp_utk")orderbyt_app.cate_p
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteCompiledSql.native_compile(NativeMethod)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:68)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:127)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:94)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:53)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1581)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1555)
07-13 18:10:37.750 E/AndroidRuntime(22384):at com.xxx.xxxx.addon.classification.AppsCategoryProvider.query(UnknownSource)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.content.ContentProvider$Transport.query(ContentProvider.java:178)
07-13 18:10:37.750 E/AndroidRuntime(22384):at android.content.ContentResolver.query(ContentResolver.java:322)
07-13 18:10:37.750 E/AndroidRuntime(22384):at com.xxx.xxx.addon.classification.AppsClassificationData1.a(UnknownSource)
07-13 18:10:37.750 E/AndroidRuntime(22384):at com.xxx.xxx.addon.classification.AppsClassificationData1.getCategoryApps(UnknownSource)
07-13 18:10:37.750 E/AndroidRuntime(22384):at com.xxx.xxx.addon.classification.LoadCategoryFolder.LoadCategoryFolderIntoWorsapce(UnknownSource)
07-13 18:10:37.750 E/AndroidRuntime(22384):at com.xxx.xxx.backup.FactoryRestoreTask.onTaskFinished(UnknownSource)
07-13 18:10:37.750 E/AndroidRuntime(22384):at com.xxx.xxx.commoninterface.ReliableWaitingThread.run(UnknownSource)
.......
解决建议:根据log提示,查找sql相关操作的正确性,有没有表,表为空等。。。




13)Android.os.NetworkOnMainThreadException

官方描述:当应用程序试图在主线程执行网络操作时抛出的异常。这只针对应用程序是Honeycomb SDK或更高版本时才抛出的异常。在早期的SDK版本允许在主线程执行网络操作,但是效果很不好。
分析:略
Testin测试日志示例:



01-21 17:42:53.969: E/AndroidRuntime(7317): FATAL EXCEPTION: main
01-21 17:42:53.969: E/AndroidRuntime(7317): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.itesterror/com.example.itesterror.MainActivity}: android.os.NetworkOnMainThreadException
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.ActivityThread.access$600(ActivityThread.java:133)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.os.Looper.loop(Looper.java:137)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.ActivityThread.main(ActivityThread.java:4802)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at java.lang.reflect.Method.invoke(Method.java:511)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at dalvik.system.NativeStart.main(Native Method)
01-21 17:42:53.969: E/AndroidRuntime(7317): Caused by: android.os.NetworkOnMainThreadException
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1121)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at java.net.InetAddress.getAllByName(InetAddress.java:214)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at com.example.itesterror.MainActivity.onCreate(MainActivity.java:45)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.Activity.performCreate(Activity.java:5045)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
01-21 17:42:53.969: E/AndroidRuntime(7317):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
01-21 17:42:53.969: E/AndroidRuntime(7317):     ... 11 more
解决建议:
1.在主线程中使用StrictMode。
2.启动线程执行访问网络的功能。




14)Android.util.AndroidRuntimeException


官方描述:android框架抛出的未被检查的基类的异常。
分析:略
Testin测试日志示例:



07-17 18:24:24.787 E/AndroidRuntime(7693):FATAL EXCEPTION:main
07-17 18:24:24.787 E/AndroidRuntime(7693):java.lang.RuntimeException:Unable to start activity ComponentInfo{com.xxx.cnlive3/com.xxx.activity.AppActivity}:android.util.AndroidRuntimeException:requestFeature()must be called before adding content
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.os.Looper.loop(Looper.java:137)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.ActivityThread.main(ActivityThread.java:5039)
07-17 18:24:24.787 E/AndroidRuntime(7693):at java.lang.reflect.Method.invokeNative(NativeMethod)
07-17 18:24:24.787 E/AndroidRuntime(7693):at java.lang.reflect.Method.invoke(Method.java:511)
07-17 18:24:24.787 E/AndroidRuntime(7693):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-17 18:24:24.787 E/AndroidRuntime(7693):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-17 18:24:24.787 E/AndroidRuntime(7693):at dalvik.system.NativeStart.main(NativeMethod)
07-17 18:24:24.787 E/AndroidRuntime(7693):Caused by:android.util.AndroidRuntimeException:requestFeature()must be called before adding content
07-17 18:24:24.787 E/AndroidRuntime(7693):at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:229)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.Activity.requestWindowFeature(Activity.java:3244)
07-17 18:24:24.787 E/AndroidRuntime(7693):at com.xxx.video.VenusActivity.onCreate(VenusActivity.java:451)
07-17 18:24:24.787 E/AndroidRuntime(7693):at com.xxx.activity.AppActivity.onCreate(AppActivity.java:61)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.Activity.performCreate(Activity.java:5104)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-17 18:24:24.787 E/AndroidRuntime(7693):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
......
 解决建议:略




15)Android.view.ViewRootImpl$CalledFromWrongThreadException

官方描述:不能在子线程直接更新ui线程的信息,否则系统会抛出此异常。
分析:略
Testin测试日志示例:略

解决建议:
1.尽量在主线程做ui操作。
2.可在子线程发消息到主线程,使之做ui想关操作。


16)Android.view.WindowManager$BadTokenException

官方描述:当添加view时,它的WindowManager.LayoutParams 的token 为空时抛出的异常。
分析:
Testin测试日志示例:



10-29 20:20:11.159 E/AndroidRuntime(10874):FATAL EXCEPTION:main
10-29 20:20:11.159 E/AndroidRuntime(10874):android.view.WindowManager$BadTokenException:Unable to add window--token null is no tvalid;is your activity running?
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.view.ViewRootImpl.setView(ViewRootImpl.java:590)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:326)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.view.Window$LocalWindowManager.addView(Window.java:547)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.widget.PopupWindow.invokePopup(PopupWindow.java:988)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:897)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:860)
10-29 20:20:11.159 E/AndroidRuntime(10874):at com.xxx.ui.control.GuideTip.showNotifyAsDrop(GuideTip.java:239)
10-29 20:20:11.159 E/AndroidRuntime(10874):at com.xxx.ui.control.GuideTip$1.handleMessage(GuideTip.java:194)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.os.Looper.loop(Looper.java:137)
10-29 20:20:11.159 E/AndroidRuntime(10874):at android.app.ActivityThread.main(ActivityThread.java:4802)
10-29 20:20:11.159 E/AndroidRuntime(10874):at java.lang.reflect.Method.invokeNative(NativeMethod)
10-29 20:20:11.159 E/AndroidRuntime(10874):at java.lang.reflect.Method.invoke(Method.java:511)
10-29 20:20:11.159 E/AndroidRuntime(10874):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
10-29 20:20:11.159 E/AndroidRuntime(10874):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
10-29 20:20:11.159 E/AndroidRuntime(10874):at dalvik.system.NativeStart.main(NativeMethod)
......
解决建议:
1.查看传入的context是否正常。
2.查看windowManager.layoutParams的参数。




17)Com.badlogic.gdx.utils.GdxRuntimeException

官方描述:略
分析:一般是在android游戏开发中使用Libgdx引擎所产生的问题。
Testin测试日志示例
解决建议:检查图片能否加载,加载是否正常等


18)JavaioFileNotFoundException

官方描述:当试图打开指定路径名表示的文件失败时,抛出此异常。在不存在具有指定路径名的文件时,此异常将由 FileInputStream、FileOutputStream 和 RandomAccessFile 构造方法抛出。如果该文件存在,但是由于某些原因不可访问,比如试图打开一个只读文件进行写入,此时这些构造方法仍然会抛出该异常。
分析:略
Testin测试日志示例:



12-12 19:45:50.978 E/AndroidRuntime(491):Uncaught handler:thread main exiting due to uncaught exception
12-12 19:45:51.018 W/System.err(491):java.io.FileNotFoundException:/data/logcat_0.txt(Permissiondenied)
12-12 19:45:51.018 E/AndroidRuntime(491):FATAL EXCEPTION:main
12-12 19:45:51.018 E/AndroidRuntime(491):java.lang.NullPointerException
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.ui.fragment.ChannelSortFragment.initTagView(ChannelSortFragment.java:667)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.ui.fragment.ChannelSortFragment.bindViews(ChannelSortFragment.java:407)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.ui.fragment.ChannelSortFragment.onSuccessHandle(ChannelSortFragment.java:385)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.ui.fragment.ChannelSortFragment.access$300(ChannelSortFragment.java:76)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.ui.fragment.ChannelSortFragment$2.onSuccess(ChannelSortFragment.java:317)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.network.HttpRequestManager$1.onPostExecute(HttpRequestManager.java:362)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.network.xxxAsyncTask.finish(xxxAsyncTask.java:348)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.network.xxxAsyncTask.access$300(xxxAsyncTask.java:32)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.xxx.network.xxxAsyncTask$InternalHandler.handleMessage(xxxAsyncTask.java:360)
12-12 19:45:51.018 E/AndroidRuntime(491):at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 19:45:51.018 E/AndroidRuntime(491):at android.os.Looper.loop(Looper.java:130)
12-12 19:45:51.018 E/AndroidRuntime(491):at android.app.ActivityThread.main(ActivityThread.java:3683)
12-12 19:45:51.018 E/AndroidRuntime(491):at java.lang.reflect.Method.invokeNative(NativeMethod)
12-12 19:45:51.018 E/AndroidRuntime(491):at java.lang.reflect.Method.invoke(Method.java:507)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
12-12 19:45:51.018 E/AndroidRuntime(491):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
12-12 19:45:51.018 E/AndroidRuntime(491):at dalvik.system.NativeStart.main(NativeMethod)
12-12 19:45:51.138 W/System.err(491):java.io.FileNotFoundException:/data/plog.log(Permissiondenied)
......
解决建议:
1.检查文件是否存在,路径是否正确。
2.检查文件读写权限。




19)Java.io.IOException

官方描述:当发生某种 I/O 异常时,抛出此异常。此类为异常的通用类,它是由失败的或中断的 I/O 操作生成的。
分析:略
Testin测试日志示例:



01-21 16:29:50.739: W/System.err(2504): java.io.FileNotFoundException: /e:/fileName.txt: open failed: ENOENT (No such file or directory)
01-21 16:29:50.739: W/System.err(2504):     at libcore.io.IoBridge.open(IoBridge.java:416)
01-21 16:29:50.739: W/System.err(2504):     at java.io.FileOutputStream.<init>(FileOutputStream.java:100)
01-21 16:29:50.739: W/System.err(2504):     at java.io.FileOutputStream.<init>(FileOutputStream.java:85)
01-21 16:29:50.739: W/System.err(2504):     at com.example.itesterror.MainActivity.onCreate(MainActivity.java:51)
01-21 16:29:50.739: W/System.err(2504):     at android.app.Activity.performCreate(Activity.java:5045)
01-21 16:29:50.739: W/System.err(2504):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
01-21 16:29:50.739: W/System.err(2504):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
01-21 16:29:50.739: W/System.err(2504):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
01-21 16:29:50.739: W/System.err(2504):     at android.app.ActivityThread.access$600(ActivityThread.java:133)
01-21 16:29:50.739: W/System.err(2504):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
01-21 16:29:50.739: W/System.err(2504):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 16:29:50.739: W/System.err(2504):     at android.os.Looper.loop(Looper.java:137)
01-21 16:29:50.739: W/System.err(2504):     at android.app.ActivityThread.main(ActivityThread.java:4802)
01-21 16:29:50.739: W/System.err(2504):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 16:29:50.739: W/System.err(2504):     at java.lang.reflect.Method.invoke(Method.java:511)
01-21 16:29:50.739: W/System.err(2504):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-21 16:29:50.739: W/System.err(2504):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-21 16:29:50.739: W/System.err(2504):     at dalvik.system.NativeStart.main(Native Method)
01-21 16:29:50.739: W/System.err(2504): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
01-21 16:29:50.739: W/System.err(2504):     at libcore.io.Posix.open(Native Method)
01-21 16:29:50.739: W/System.err(2504):     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
01-21 16:29:50.739: W/System.err(2504):     at libcore.io.IoBridge.open(IoBridge.java:400)
......

解决建议:检查文件,stream的读写操作。
 



20) JavalangArithmeticException

官方描述:当出现异常的运算条件时,抛出此异常。
分析:略
Testin测试日志示例:



01-21 16:22:50.959: E/AndroidRuntime(1866): FATAL EXCEPTION: main
01-21 16:22:50.959: E/AndroidRuntime(1866): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.itesterror/com.example.itesterror.MainActivity}: java.lang.ArithmeticException: divide by zero
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.ActivityThread.access$600(ActivityThread.java:133)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.os.Looper.loop(Looper.java:137)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.ActivityThread.main(ActivityThread.java:4802)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at java.lang.reflect.Method.invoke(Method.java:511)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at dalvik.system.NativeStart.main(Native Method)
01-21 16:22:50.959: E/AndroidRuntime(1866): Caused by: java.lang.ArithmeticException: divide by zero
01-21 16:22:50.959: E/AndroidRuntime(1866):     at com.example.itesterror.MainActivity.onCreate(MainActivity.java:35)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.Activity.performCreate(Activity.java:5045)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
01-21 16:22:50.959: E/AndroidRuntime(1866):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
01-21 16:22:50.959: E/AndroidRuntime(1866):     ... 11 more
解决建议:
这个异常的解释是 "数学运算异常 ",比如程序中出现了除以零这样的运算就会出这样的异常,对这种异常,检查一下自己程序中涉及到数学运算的地方,公式是不是有不妥了。




21)Java.lang.ArrayIndexOutOfBoundsException

官方描述:这个异常的解释是 "数组下标越界 ",用非法索引访问数组时抛出的异常。
分析:略
Testin测试日志示例:



01-21 16:17:41.159: E/AndroidRuntime(1269): FATAL EXCEPTION: main
01-21 16:17:41.159: E/AndroidRuntime(1269): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.itesterror/com.example.itesterror.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.ActivityThread.access$600(ActivityThread.java:133)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.os.Looper.loop(Looper.java:137)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.ActivityThread.main(ActivityThread.java:4802)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at java.lang.reflect.Method.invoke(Method.java:511)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at dalvik.system.NativeStart.main(Native Method)
01-21 16:17:41.159: E/AndroidRuntime(1269): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
01-21 16:17:41.159: E/AndroidRuntime(1269):     at com.example.itesterror.MainActivity.onCreate(MainActivity.java:32)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.Activity.performCreate(Activity.java:5045)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
01-21 16:17:41.159: E/AndroidRuntime(1269):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
01-21 16:17:41.159: E/AndroidRuntime(1269):     ... 11 more
解决建议:检查数组下标是否超出数组的范围。下标为负或大于等于数组的大小都是超出范围。




22)Java.lang.ClassCastException

官方描述:当试图将对象强制转换为不是实例的子类时,抛出该异常。
分析:略
Testin测试日志示例:



11-18 18:28:19.291 E/AndroidRuntime(21236):FATAL EXCEPTION:main
11-18 18:28:19.291 E/AndroidRuntime(21236):java.lang.ClassCastException:com.xxx.xxx.adapter.b.acannotbecasttocom.xxx.xxx.adapter.b.b
11-18 18:28:19.291 E/AndroidRuntime(21236):at com.xxx.xxx.MainTab.UpdateVersionActivity$8.onItemClick(UpdateVersionActivity.java:232)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.widget.AdapterView.performItemClick(AdapterView.java:319)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.widget.AbsListView.performItemClick(AbsListView.java:1234)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.widget.AbsListView.onKeyUp(AbsListView.java:2908)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.widget.ListView.commonKey(ListView.java:2242)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.widget.ListView.onKeyUp(ListView.java:2097)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.KeyEvent.dispatch(KeyEvent.java:2575)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.View.dispatchKeyEvent(View.java:5506)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1248)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.widget.ListView.dispatchKeyEvent(ListView.java:2072)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1252)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1252)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1252)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1252)
11-18 18:28:19.291 E/AndroidRuntime(21236):at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1920)
11-18 18:28:19.291 E/AndroidRuntime(21236):at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1387)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.app.Activity.dispatchKeyEvent(Activity.java:2391)
11-18 18:28:19.291 E/AndroidRuntime(21236):at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1832)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3568)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3540)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2660)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.os.Handler.dispatchMessage(Handler.java:99)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.os.Looper.loop(Looper.java:154)
11-18 18:28:19.291 E/AndroidRuntime(21236):at android.app.ActivityThread.main(ActivityThread.java:4631)
11-18 18:28:19.291 E/AndroidRuntime(21236):at java.lang.reflect.Method.invokeNative(NativeMethod)
11-18 18:28:19.291 E/AndroidRuntime(21236):at java.lang.reflect.Method.invoke(Method.java:511)
11-18 18:28:19.291 E/AndroidRuntime(21236):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
11-18 18:28:19.291 E/AndroidRuntime(21236):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
11-18 18:28:19.291 E/AndroidRuntime(21236):at dalvik.system.NativeStart.main(NativeMethod)
......

代码示例:例如,以下代码将生成一个 ClassCastException: 
Object x = new Integer(0);



System.out.println((String)x);

解决建议:定位问题行,查看转换的正确性。


23)Java.lang.ClassNotFoundException

官方描述:当应用程序试图使用以下方法通过字符串名加载类时,抛出该异常:
Class 类中的 forName 方法。
ClassLoader 类中的 findSystemClass 方法。
ClassLoader 类中的 loadClass 方法。
但是没有找到具有指定名称的类的定义。
分析:略
Testin测试日志示例:



08-15 14:54:35.490 E/AndroidRuntime(17753):FATAL EXCEPTION:main
08-15 14:54:35.490 E/AndroidRuntime(17753):java.lang.RuntimeException:Unable to instantiate application xxx.xxx.xxx:java.lang.ClassNotFoundException:xxx.xxx.xxx
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.ActivityThread.access$1300(ActivityThread.java:123)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.os.Looper.loop(Looper.java:137)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.ActivityThread.main(ActivityThread.java:4424)
08-15 14:54:35.490 E/AndroidRuntime(17753):at java.lang.reflect.Method.invokeNative(NativeMethod)
08-15 14:54:35.490 E/AndroidRuntime(17753):at java.lang.reflect.Method.invoke(Method.java:511)
08-15 14:54:35.490 E/AndroidRuntime(17753):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-15 14:54:35.490 E/AndroidRuntime(17753):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-15 14:54:35.490 E/AndroidRuntime(17753):at dalvik.system.NativeStart.main(NativeMethod)
08-15 14:54:35.490 E/AndroidRuntime(17753):Caused by:java.lang.ClassNotFoundException:xxx.xxx.xxx
08-15 14:54:35.490 E/AndroidRuntime(17753):at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-15 14:54:35.490 E/AndroidRuntime(17753):at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-15 14:54:35.490 E/AndroidRuntime(17753):at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.Instrumentation.newApplication(Instrumentation.java:942)
08-15 14:54:35.490 E/AndroidRuntime(17753):at android.app.LoadedApk.makeApplication(LoadedApk.java:477)
......
解决建议:这个异常的解释是 "指定的类不存在 ",这里主要考虑一下类的名称和路径是否正确。




24)Java.lang.CloneNotSupportedException

官方描述:当调用 Object 类中的 clone 方法复制对象,但该对象的类无法实现 Cloneable 接口时,抛出该异常。 重写 clone 方法的应用程序也可能抛出此异常,指示不能或不应复制一个对象。
分析:略
Testin测试日志示例:略
解决建议:略


25)Java.lang.Error

官方描述:Error 是 Throwable 的子类,用于指示合理的应用程序不应该试图捕获的严重问题。大多数这样的错误都是异常条件。虽然 ThreadDeath 错误是一个“正规”的条件,但它也是 Error 的子类,因为大多数应用程序都不应该试图捕获它。
分析:
Testin测试日志示例:



Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Cannot make a static reference to the non-static field max
Cannot make a static reference to the non-static field min
at com.testin.qtestin.Main.main(Main.java:76)
解决建议:ava的错误代码,根据log定位,可直接找到错误所在。在执行该方法期间,无需在其 throws 子句中声明可能抛出但是未能捕获的 Error 的任何子类,因为这些错误可能是再也不会发生的异常条件。




26)Java.lang.IllegalStateException

官方描述:在不合理或不正确时间内唤醒一方法时出现的异常信息。换句话说,即 Java 环境或 Java 应用不满足请求操作。
分析:略
Testin测试日志示例



09-10 15:53:07.249 E/AndroidRuntime(24374):FATAL EXCEPTION:main
09-10 15:53:07.249 E/AndroidRuntime(24374):java.lang.RuntimeException:Unable to start activity ComponentInfo{com.xxx.xxxx/com.xxx.xxx.Main}:java.lang.IllegalStateException:Thespecifiedchildalreadyhasaparent.You must call remove View()on the child's parent first.
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.ActivityThread.access$600(ActivityThread.java:133)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.os.Looper.loop(Looper.java:137)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.ActivityThread.main(ActivityThread.java:4802)
09-10 15:53:07.249 E/AndroidRuntime(24374):at java.lang.reflect.Method.invokeNative(NativeMethod)
09-10 15:53:07.249 E/AndroidRuntime(24374):at java.lang.reflect.Method.invoke(Method.java:511)
09-10 15:53:07.249 E/AndroidRuntime(24374):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
09-10 15:53:07.249 E/AndroidRuntime(24374):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
09-10 15:53:07.249 E/AndroidRuntime(24374):at dalvik.system.NativeStart.main(NativeMethod)
09-10 15:53:07.249 E/AndroidRuntime(24374):Caused by:java.lang.IllegalStateException:The specified child already has a parent.You must call remove View()on the child's parent first.
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.view.ViewGroup.addViewInner(ViewGroup.java:3378)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.view.ViewGroup.addView(ViewGroup.java:3249)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.view.ViewGroup.addView(ViewGroup.java:3225)
09-10 15:53:07.249 E/AndroidRuntime(24374):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:279)
09-10 15:53:07.249 E/AndroidRuntime(24374):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:269)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.Activity.setContentView(Activity.java:1917)
09-10 15:53:07.249 E/AndroidRuntime(24374):at com.soco.veggies2_91.Main.start(Main.java:297)
09-10 15:53:07.249 E/AndroidRuntime(24374):at com.socoGameEngine.MainActivity.onCreate(MainActivity.java:79)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.Activity.performCreate(Activity.java:5045)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
09-10 15:53:07.249 E/AndroidRuntime(24374):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
 ......                  

解决建议:通过log可清晰定位问题,根据具体情况解决。



27)Java.lang.IllegalThreadStateException



官方描述:指示线程没有处于请求操作所要求的适当状态时抛出的异常。例如,请参见 Thread 类中的 suspend 和 resume 方法。
分析:略
Testin测试日志示例
01-21 16:12:49.219: E/AndroidRuntime(654): FATAL EXCEPTION: main
01-21 16:12:49.219: E/AndroidRuntime(654): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.itesterror/com.example.itesterror.MainActivity}: java.lang.IllegalThreadStateException: Thread already started.
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.ActivityThread.access$600(ActivityThread.java:133)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.os.Looper.loop(Looper.java:137)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.ActivityThread.main(ActivityThread.java:4802)
01-21 16:12:49.219: E/AndroidRuntime(654):     at java.lang.reflect.Method.invokeNative(Native Method)
01-21 16:12:49.219: E/AndroidRuntime(654):     at java.lang.reflect.Method.invoke(Method.java:511)
01-21 16:12:49.219: E/AndroidRuntime(654):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-21 16:12:49.219: E/AndroidRuntime(654):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-21 16:12:49.219: E/AndroidRuntime(654):     at dalvik.system.NativeStart.main(Native Method)
01-21 16:12:49.219: E/AndroidRuntime(654): Caused by: java.lang.IllegalThreadStateException: Thread already started.
01-21 16:12:49.219: E/AndroidRuntime(654):     at java.lang.Thread.start(Thread.java:1045)
01-21 16:12:49.219: E/AndroidRuntime(654):     at com.example.itesterror.MainActivity.onCreate(MainActivity.java:28)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.Activity.performCreate(Activity.java:5045)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
01-21 16:12:49.219: E/AndroidRuntime(654):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
01-21 16:12:49.219: E/AndroidRuntime(654):     ...&