Android稳定性专题之CRASH

来源:互联网 发布:哪类商品禁止在淘宝网 编辑:程序博客网 时间:2024/06/05 20:09


1. CRASH问题

Crash问题是最为常见的Android应用稳定性问题之一,具体表现为应用程序异常退出,比如闪退,Force Close等。

对于业务复杂、架构复杂的超级App而言,Crash问题如影随形,无法完全根除。业界中,一般引入Crash率,来评价衡量软件的稳定性。为了达到更低的Crash率,获取更好的稳定性,这对研发人员提出了更高的要求。

下面让我们解开Crash问题的面纱,一探究竟,降服这只怪兽。

2. CRASH技术原理

2.1 CRASH分类

从Android应用开发的角度来看,Crash问题可以分成两种类型:App Crash,Native Crash。

  • App Crash:Java层Crash,由于应用程序的Java层抛出了“未捕获异常(Uncaught Exception)”,从而导致了程序异常退出。
    Java程序中的空指针错误,数组越界等错误,在子线程中刷新UI等错误都会导致异常抛出,造成Crash。
  • Native Crash:Native层(C/C++)Crash,当程序出现异常时,比如空指针,数组越界等。与Java层抛出异常不同,此时系统Kernel会发送相应的signal,从而导致程序异常退出。

          工作中常见的Crash signal类型如下:

 

Signal

Value

Description

SIGSEGV

11

Invalid memory reference.

SIGBUS

7

Access to an undefined portion of a memory object.

SIGFPE

8

Arithmetic operation error, like divide by zero.

SIGILL

4

Illegal instruction, like execute garbage or a privileged instruction

SIGSYS

31

Bad system call.

SIGXCPU

24

CPU time limit exceeded.

SIGXFSZ

25

File size limit exceeded.

2.2 CRASH日志的生成

下面两小节将分别介绍Crash日志生成的原理,有助于后续的问题分析和解决。

2.2.1 App Crash日志的生成

当发生App Crash时,系统会将日志写入/data/system/dropbox 路径下的日志文件中。当然,在logcat的日志中也会有体现。

阅读Android系统源码可以了解到系统的处理流程大致如下:

  1. 发生crash的进程,在创建之初便准备好了defaultUncaughtHandler,用来来处理Uncaught Exception,并输出当前crash基本信息;
  2. 调用当前进程中的AMP.handleApplicationCrash;经过binder ipc机制,传递到system_server进程;
  3. 接下来,进入system_server进程,调用binder服务端执行AMS.handleApplicationCrash;
  4. 从mProcessNames查找到目标进程的ProcessRecord对象;并将进程crash信息输出到  /data/system/dropbox 路径下;
  5. 执行makeAppCrashingLocked
    • 创建当前用户下的crash应用的error receiver,并忽略当前应用的广播;
    • 停止当前进程中所有activity中的WMS的冻结屏幕消息,并执行相关一些屏幕相关操作;
  6. 再执行handleAppCrashLocked方法
  7. 通过mUiHandler发送消息SHOW_ERROR_MSG,弹出crash对话框
  8. 到此,system_server进程执行完成。回到crash进程开始执行杀掉当前进程的操作;
  9. 当crash进程被杀,通过binder死亡通知,告知system_server进程来执行appDiedLocked();
  10. 最后,执行清理应用相关的activity/service/ContentProvider/receiver组件信息。

2.2.2 Native Crash日志的生成

当发生Native Crash时,系统会将日志写入/data/tombstones/tombstone_XX日志文件中(其中XX为序号)。同时Crash日志也会保存到dropbox路径下。

阅读Android系统源码可以了解到系统的处理流程大致如下:

  1. 其中,标红的perform_dump阶段,将crash日志写入/data/tombstones路径下的日志文件中。
  2. 最后交由AMS进行handleApplicationCrashInner阶段,也会将Crash信息写入dropbox路径下。

2.2.3 权限的问题

以上2.2.1和2.2.2分别介绍了App Crash和Native Crash发生时,系统如何生成相关日志信息以及日志保存的路径。

工作中会发现,要访问/data/system/dropbox 以及 /data/tombstones路径,都需要root权限。如果手头上没有root过的手机只能尽力在logcat日志中寻找线索了,祝好运吧 ^_^

由于厂商测试中使用的ROM一般都有root权限,所以厂商提供的日志文件大部分都包含dropbox和tombstone路径下的日志文件。

另一方面也要看厂商对系统定制、修改的情况,不排除由于厂商修改了系统策略,日志存储变化的情况。

2.3 CRASH日志的收集

当APP已经发版,大量用户在使用中如果发生了APP Crash,我们如何能尽快发现并第一时间解决呢?这就涉及到如何尽快把发生问题的信息收集上来,具体的说就是把Crash日志从发生问题的手机上采集回来。从上一节,我们知道没有root过的手机,应用程序是无法访问/data/system/dropbox 和 /data/tombstones路径的。那么如何收集Crash日志呢?

2.3.1 App Crash日志的收集

Java中提供了Thread.UncaughtExceptionHandler用来捕获“未捕获异常”。我们可以实现自己的UncaughtExceptionHandler来获取App Crash信息,然后保存在本地文件中。在合适的时机下,将日志信息回传到统计平台。这样我们就能尽快的了解到发出去版本的Crash信息,从而尽快的将问题修复。

可以参考地图中的代码BaiduMapApplication和BMUncaughtExceptionHandler了解细节。

注:经过在真机上验证,实现了自定义的UncaughtExceptionHandler之后,dropbox目录下将无法自动生成App Crash的日志文件了。

2.3.2 Native Crash日志的收集

相对于App Crash,Native Crash的日志收集要复杂一些。由于系统没有提供获取Native Crash的接口,所以无法使用Android自带的任何API来实现这个功能。当前地图选取了Breakpad工具来手机Native层的Crash日志。

Breakpad是由Google提供的开源项目,用于Native层崩溃日志的收集。Chrome,Firefox,Picasa,Google Earth等项目也都在使用它。这里简单介绍一下BreakPad的主要工作流程。

如上图所示:

  1. Breakpad分成服务端和客户端,两个部分。
  2. 应用程序,比如百度地图,在编译打包过程中,breakpad的symbol dumper会读取符号表等调试信息,生成基于Breakpad格式的符号表。这份符号表保存在Breakpad的服务端。
  3. 正常发布的so文件不携带符号表信息。发布的App中集成了Breakpad的client模块。
  4. 当Native Crash发生时,Breakpad的Client模块会收集日志,并将日志写入minidump中。
  5. 适当的时机下,minidump日志会回传给服务端。
  6. 服务端,Breakpad的Processor模块会读取minidump,结合之前保存的符号表生成可读的调用栈信息。

 

更多细节可以参考地图代码中的模块 /subModules/nacrashcollector 和 地图Crash日志平台。

3. 测试手段

3.1 Monkey测试

稳定性测试一般通过自动化手段完成。Android SDK提供了“monkey”这个自动化测试工具。它可以运行在模拟器里或实际设备中,向系统发送随机的用户事件流,如按键输入、触摸屏输入、手势输入、Sensor 事件等, 实现对应用程序的压力测试。

执行方法:

1)  adb shell 连接到手机,进入命令行。

2)  执行命令

monkey --pct-touch 45 --pct-motion 20 --pct-majornav 10 --pct-appswitch 15 --pct-anyevent 10 --ignore-crashes --ignore-timeouts --ignore-security-exceptions –p com.baidu.BaiduMap --monitor-native-crashes --throttle 2000 -v 490000                                 

3)  可以把Monkey日志重定向到sdcard上,每次测试结束之后进行检查。

3.2 QA自动化测试平台

 

附录

附录1:Monkey命令参数说明

1) 参数: -p 
参数-p用于约束限制,用此参数指定一个或多个包(Package,即App)。指定 
包之后,Monkey将只允许系统启动指定的APP。如果不指定包,Monkey将允许系统启动设备中的所有APP。 
* 指定一个包: adb shell monkey -p com.baidu.BaiduMap 100 
说明:com.baidu.BaiduMap为包名,100是事件计数(即让Monkey程序模拟100次随机用户事件)。 
* 指定多个包:adb shell monkey -p com.baidu.BaiduMap –p com.baidu.aaa -p com.baidu.bbb 100 
* 不指定包:adb shell monkey 100 
说明:Monkey随机启动APP并发送100个随机事件。 
* 要查看设备中所有的包,在CMD窗口中执行以下命令: 
>adb shell 
#cd data/data 
#ls 

2) 参数: -v 
用于指定反馈信息级别(信息级别就是日志的详细程度),总共分3个级别,分别对应的参数如下表所示: 
日志级别 Level 0 
示例 adb shell monkey -p com.baidu.BaiduMap –v 100 
说明 缺省值,仅提供启动提示、测试完成和最终结果等少量信息 

日志级别 Level 1 
示例 adb shell monkey -p com.baidu.BaiduMap –v -v 100 
说明 提供较为详细的日志,包括每个发送到Activity的事件信息 

日志级别 Level 2 
示例 adb shell monkey -p com.baidu.BaiduMap –v -v –v 100 
说明 最详细的日志,包括了测试中选中/未选中的Activity信息 

3)参数: -s 
用于指定伪随机数生成器的seed值,如果seed相同,则两次Monkey测试所产生的事件序列也相同的。 
* 示例: 
Monkey测试1:adb shell monkey -p com.baidu.BaiduMap –s 10 100 
Monkey 测试2:adb shell monkey -p com.baidu.BaiduMap –s 10 100 
两次测试的效果是相同的,因为模拟的用户操作序列(每次操作按照一定的先后顺序所组成的一系列操作,即一个序列)是一样的。操作序列虽 然是随机生成的,但是只要我们指定了相同的Seed值,就可以保证两次测试产生的随机操作序列是完全相同的,所以这个操作序列伪随机的; 

4) 参数: --throttle <毫秒> 
用于指定用户操作(即事件)间的时延,单位是毫秒; 
* 示例:adb shell monkey -p com.baidu.BaiduMap –throttle 3000 100 

5) 参数: --ignore-crashes 
用于指定当应用程序崩溃时(Force & Close错误),Monkey是否停止运行。如果使用此参数,即使应用程序崩溃,Monkey依然会发送事件,直到事件计数完成。 
* 示例1:adb shell monkey -p com.baidu.BaiduMap --ignore-crashes 1000 
测试过程中即使Weather程序崩溃,Monkey依然会继续发送事件直到事件数目达到1000为止; 
* 示例2:adb shell monkey -p com.baidu.BaiduMap 1000 
测试过程中,如果Weather程序崩溃,Monkey将会停止运行。 


6) 参数: --ignore-timeouts 
用于指定当应用程序发生ANR(Application No Responding)错误时,Monkey是否停止运行。如果使用此参数,即使应用程序发生ANR错误,Monkey依然会发送事件,直到事件计数完成。 

7) 参数: --ignore-security-exceptions 
用于指定当应用程序发生许可错误时(如证书许可,网络许可等),Monkey是否停止运行。如果使用此参数,即使应用程序发生许可错误,Monkey依然会发送事件,直到事件计数完成。 

8) 参数: --kill-process-after-error 
用于指定当应用程序发生错误时,是否停止其运行。如果指定此参数,当应用程序发生错误时,应用程序停止运行并保持在当前状态(注意:应用程序仅是静止在发生错误时的状态,系统并不会结束该应用程序的进程)。 

9) 参数: --monitor-native-crashes 
用于指定是否监视并报告应用程序发生崩溃的本地代码。 

10) 参数: --pct-{+事件类别} {+事件类别百分比} 
用于指定每种类别事件的数目百分比(在Monkey事件序列中,该类事件数目占总事件数目的百分比) 

示例: 

--pct-touch {+百分比} 
调整触摸事件的百分比(触摸事件是一个down-up事件,它发生在屏幕上的某单一位置) 
adb shell monkey -p com.baidu.BaiduMap --pct-touch 10 1000 

--pct-motion {+百分比} 
调整动作事件的百分比(动作事件由屏幕上某处的一个down事件、一系列的伪随机事件和一个up事件组成)adb shell monkey -p com.baidu.BaiduMap --pct-motion 20 1000 

--pct-trackball {+百分比} 
调整轨迹事件的百分比(轨迹事件由一个或几个随机的移动组成,有时还伴随有点击) 
adb shell monkey -p com.baidu.BaiduMap --pct-trackball 30 1000 
--pct-nav {+百分比} 

调整“基本”导航事件的百分比(导航事件由来自方向输入设备的up/down/left/right组成) 
adb shell monkey -p com.baidu.BaiduMap --pct-nav 40 1000 

--pct-majornav {+百分比} 
调整“主要”导航事件的百分比(这些导航事件通常引发图形界面中的动作,如:5-way键盘的中间按键、回退按键、菜单按键) 
adb shell monkey -p com.baidu.BaiduMap --pct-majornav 50 1000 

--pct-syskeys {+百分比} 
调整“系统”按键事件的百分比(这些按键通常被保留,由系统使用,如Home、Back、Start Call、End Call及音量控制键) 
adb shell monkey -p com.baidu.BaiduMap --pct-syskeys 60 1000 

--pct-appswitch {+百分比} 
调整启动Activity的百分比。在随机间隔里,Monkey将执行一个startActivity()调用,作为最大程度覆盖包中全部Activity的一种方法 
adb shell monkey -p com.baidu.BaiduMap --pct-appswitch 70 1000 

--pct-anyevent {+百分比} 
调整其它类型事件的百分比。它包罗了所有其它类型的事件,如:按键、其它不常用的设备按钮、等等 
adb shell monkey -p com.baidu.BaiduMap 

--pct -anyevent 100 1000* 指定多个类型事件的百分比: 
adb shell monkey -p com.baidu.BaiduMap --pct-anyevent 50 --pct-appswitch 50 1000

附录2:Android中的Throwable列表

 

https://developer.android.com/reference/java/lang/Throwable.html

 

AEADBadTagException

This exception is thrown when a Cipher operating in an AEAD mode (such as GCM/CCM) is unable to verify the supplied authentication tag. 

AbstractMethodError

Thrown when an application tries to call an abstract method. 

AccessControlException

This exception is thrown by the AccessController to indicate that a requested access (to a critical system resource such as the file system or the network) is denied. 

AccountsException

 

AclNotFoundException

This is an exception that is thrown whenever a reference is made to a non-existent ACL (Access Control List). 

ActivityNotFoundException

This exception is thrown when a call to startActivity(Intent) or one of its variants fails because an Activity can not be found to execute the given Intent. 

AlreadyBoundException

Unchecked exception thrown when an attempt is made to bind the socket a network oriented channel that is already bound. 

AlreadyConnectedException

Unchecked exception thrown when an attempt is made to connect a SocketChannel that is already connected. 

AndroidException

Base class for all checked exceptions thrown by the Android frameworks. 

AndroidRuntimeException

Base class for all unchecked exceptions thrown by the Android frameworks. 

AnnotationFormatError

Thrown when the annotation parser attempts to read an annotation from a class file and determines that the annotation is malformed. 

AnnotationTypeMismatchException

Thrown to indicate that a program has attempted to access an element of an annotation whose type has changed after the annotation was compiled (or serialized). 

ArithmeticException

Thrown when an exceptional arithmetic condition has occurred. 

ArrayIndexOutOfBoundsException

Thrown to indicate that an array has been accessed with an illegal index. 

ArrayStoreException

Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects. 

AssertionError

Thrown to indicate that an assertion has failed. 

AssertionFailedError

Thrown when an assertion failed. 

AsynchronousCloseException

Checked exception received by a thread when another thread closes the channel or the part of the channel upon which it is blocked in an I/O operation. 

AuthenticatorException

 

BackingStoreException

Thrown to indicate that a preferences operation could not complete because of a failure in the backing store, or a failure to contact the backing store. 

BadPaddingException

This exception is thrown when a particular padding mechanism is expected for the input data but the data is not padded properly. 

BadParcelableException

Exception thrown when a Parcelable is malformed or otherwise invalid. 

Base64DataException

This exception is thrown by Base64InputStream or Base64OutputStream when an error is detected in the data being decoded. 

BatchUpdateException

The subclass of SQLException thrown when an error occurs during a batch update operation. 

BindException

Signals that an error occurred while attempting to bind a socket to a local address and port. 

BrokenBarrierException

Exception thrown when a thread tries to wait upon a barrier that is in a broken state, or which enters the broken state while the thread is waiting. 

BufferOverflowException

Unchecked exception thrown when a relative put operation reaches the target buffer's limit. 

BufferUnderflowException

Unchecked exception thrown when a relative get operation reaches the source buffer's limit. 

CRLException

CRL (Certificate Revocation List) Exception. 

CameraAccessException

CameraAccessException is thrown if a camera device could not be queried or opened by the CameraManager, or if the connection to an opened CameraDevice is no longer valid. 

CancellationException

Exception indicating that the result of a value-producing task, such as a FutureTask, cannot be retrieved because the task was cancelled. 

CancelledKeyException

Unchecked exception thrown when an attempt is made to use a selection key that is no longer valid. 

CertPathBuilderException

An exception indicating one of a variety of problems encountered when building a certification path with a CertPathBuilder

CertPathValidatorException

An exception indicating one of a variety of problems encountered when validating a certification path. 

CertStoreException

An exception indicating one of a variety of problems retrieving certificates and CRLs from a CertStore

CertificateEncodingException

Certificate Encoding Exception. 

CertificateException

This exception indicates one of a variety of certificate problems. 

CertificateExpiredException

Certificate Expired Exception. 

CertificateNotYetValidException

Certificate is not yet valid exception. 

CertificateParsingException

Certificate Parsing Exception. 

CertificateRevokedException

An exception that indicates an X.509 certificate is revoked. 

CharConversionException

Base class for character conversion exceptions. 

CharacterCodingException

Checked exception thrown when a character encoding or decoding error occurs. 

ClassCastException

Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. 

ClassCircularityError

Thrown when the Java Virtual Machine detects a circularity in the superclass hierarchy of a class being loaded. 

ClassFormatError

Thrown when the Java Virtual Machine attempts to read a class file and determines that the file is malformed or otherwise cannot be interpreted as a class file. 

ClassNotFoundException

Thrown when an application tries to load in a class through its string name using:

  • The forName method in class Class

CloneNotSupportedException

Thrown to indicate that the clone method in class Object has been called to clone an object, but that the object's class does not implement the Cloneable interface. 

ClosedByInterruptException

Checked exception received by a thread when another thread interrupts it while it is blocked in an I/O operation upon a channel. 

ClosedChannelException

Checked exception thrown when an attempt is made to invoke or complete an I/O operation upon channel that is closed, or at least closed to that operation. 

ClosedSelectorException

Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a closed selector. 

CoderMalfunctionError

Error thrown when the decodeLoop method of a CharsetDecoder, or the encodeLoopmethod of a CharsetEncoder, throws an unexpected exception. 

ComparisonFailure

Thrown when an assert equals for Strings failed. 

CompletionException

Exception thrown when an error or other exception is encountered in the course of completing a result or task. 

ConcurrentModificationException

This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. 

ConnectException

Signals that an error occurred while attempting to connect a socket to a remote address and port. 

ConnectTimeoutException

This class was deprecated in API level 22. Please use openConnection() instead. Please visit this webpage for further details.  

ConnectionPendingException

Unchecked exception thrown when an attempt is made to connect a SocketChannel for which a non-blocking connection operation is already in progress. 

CursorIndexOutOfBoundsException

An exception indicating that a cursor is out of bounds. 

DOMException

DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impossible to perform (either for logical reasons, because data is lost, or because the implementation has become unstable). 

DataFormatException

Signals that a data format error has occurred. 

DataTruncation

An exception thrown as a DataTruncation exception (on writes) or reported as a DataTruncation warning (on reads) when a data values is unexpectedly truncated for reasons other than its having execeeded MaxFieldSize

DatatypeConfigurationException

Indicates a serious configuration error. 

DeadObjectException

The object you are calling has died, because its hosting process no longer exists. 

DeadSystemException

The core Android system has died and is going through a runtime restart. 

DeniedByServerException

Exception thrown when the provisioning server or key server denies a certficate or license for a device. 

DestroyFailedException

Signals that a destroy operation failed. 

DigestException

This is the generic Message Digest exception. 

DuplicateFormatFlagsException

Unchecked exception thrown when duplicate flags are provided in the format specifier. 

EOFException

Signals that an end of file or end of stream has been reached unexpectedly during input. 

EmptyStackException

Thrown by methods in the Stack class to indicate that the stack is empty. 

EnumConstantNotPresentException

Thrown when an application tries to access an enum constant by name and the enum type contains no constant with the specified name. 

ErrnoException

A checked exception thrown when Os methods fail. 

ExceptionInInitializerError

Signals that an unexpected exception has occurred in a static initializer. 

ExecutionException

Exception thrown when attempting to retrieve the result of a task that aborted by throwing an exception. 

ExemptionMechanismException

This is the generic ExemptionMechanism exception. 

FactoryConfigurationError

Thrown when a problem with configuration with the Parser Factories exists. 

FileLockInterruptionException

Checked exception received by a thread when another thread interrupts it while it is waiting to acquire a file lock. 

FileNotFoundException

Signals that an attempt to open the file denoted by a specified pathname has failed. 

FileUriExposedException

The exception that is thrown when an application exposes a file:// Uri to another app. 

FormatException

 

FormatFlagsConversionMismatchException

Unchecked exception thrown when a conversion and flag are incompatible. 

FormatterClosedException

Unchecked exception thrown when the formatter has been closed. 

Fragment.InstantiationException

Thrown by instantiate(Context, String, Bundle) when there is an instantiation failure. 

GLException

An exception class for OpenGL errors. 

GeneralSecurityException

The GeneralSecurityException class is a generic security exception class that provides type safety for all the security-related exception classes that extend from it. 

GenericSignatureFormatError

Thrown when a syntactically malformed signature attribute is encountered by a reflective method that needs to interpret the generic signature information for a type, method or constructor. 

HttpRetryException

Thrown to indicate that a HTTP request needs to be retried but cannot be retried automatically, due to streaming mode being enabled. 

ICUUncheckedIOException

Unchecked version of IOException. 

IOError

Thrown when a serious I/O error has occurred. 

IOException

Signals that an I/O exception of some sort has occurred. 

IllegalAccessError

Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to. 

IllegalAccessException

An IllegalAccessException is thrown when an application tries to reflectively create an instance (other than an array), set or get a field, or invoke a method, but the currently executing method does not have access to the definition of the specified class, field, method or constructor. 

IllegalArgumentException

Thrown to indicate that a method has been passed an illegal or inappropriate argument. 

IllegalBlockSizeException

This exception is thrown when the length of data provided to a block cipher is incorrect, i.e., does not match the block size of the cipher. 

IllegalBlockingModeException

Unchecked exception thrown when a blocking-mode-specific operation is invoked upon a channel in the incorrect blocking mode. 

IllegalCharsetNameException

Unchecked exception thrown when a string that is not a legal charset name is used as such. 

IllegalFormatCodePointException

Unchecked exception thrown when a character with an invalid Unicode code point as defined by isValidCodePoint(int) is passed to the Formatter. 

IllegalFormatConversionException

Unchecked exception thrown when the argument corresponding to the format specifier is of an incompatible type. 

IllegalFormatException

Unchecked exception thrown when a format string contains an illegal syntax or a format specifier that is incompatible with the given arguments. 

IllegalFormatFlagsException

Unchecked exception thrown when an illegal combination flags is given. 

IllegalFormatPrecisionException

Unchecked exception thrown when the precision is a negative value other than -1, the conversion does not support a precision, or the value is otherwise unsupported. 

IllegalFormatWidthException

Unchecked exception thrown when the format width is a negative value other than -1 or is otherwise unsupported. 

IllegalMonitorStateException

Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor. 

IllegalSelectorException

Unchecked exception thrown when an attempt is made to register a channel with a selector that was not created by the provider that created the channel. 

IllegalStateException

Signals that a method has been invoked at an illegal or inappropriate time. 

IllegalThreadStateException

Thrown to indicate that a thread is not in an appropriate state for the requested operation. 

IncompatibleClassChangeError

Thrown when an incompatible class change has occurred to some class definition. 

IncompleteAnnotationException

Thrown to indicate that a program has attempted to access an element of an annotation type that was added to the annotation type definition after the annotation was compiled (or serialized). 

IndexOutOfBoundsException

Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range. 

InflateException

This exception is thrown by an inflater on error conditions. 

InputMismatchException

Thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type. 

InstantiationError

Thrown when an application tries to use the Java new construct to instantiate an abstract class or an interface. 

InstantiationException

Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated. 

IntentFilter.MalformedMimeTypeException

This exception is thrown when a given MIME type does not have a valid syntax. 

IntentSender.SendIntentException

Exception thrown when trying to send through a PendingIntent that has been canceled or is otherwise no longer able to execute the request. 

InternalError

Thrown to indicate some unexpected internal error has occurred in the Java Virtual Machine. 

InterruptedException

Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. 

InterruptedIOException

Signals that an I/O operation has been interrupted. 

InvalidAlgorithmParameterException

This is the exception for invalid or inappropriate algorithm parameters. 

InvalidClassException

Thrown when the Serialization runtime detects one of the following problems with a Class. 

InvalidKeyException

This is the exception for invalid Keys (invalid encoding, wrong length, uninitialized, etc). 

InvalidKeySpecException

This is the exception for invalid key specifications. 

InvalidMarkException

Unchecked exception thrown when an attempt is made to reset a buffer when its mark is not defined. 

InvalidObjectException

Indicates that one or more deserialized objects failed validation tests. 

InvalidParameterException

This exception, designed for use by the JCA/JCE engine classes, is thrown when an invalid parameter is passed to a method. 

InvalidParameterSpecException

This is the exception for invalid parameter specifications. 

InvalidPreferencesFormatException

Thrown to indicate that an operation could not complete because the input did not conform to the appropriate XML document type for a collection of preferences, as per the Preferences specification. 

InvalidPropertiesFormatException

Thrown to indicate that an operation could not complete because the input did not conform to the appropriate XML document type for a collection of properties, as per the Properties specification. 

InvocationTargetException

InvocationTargetException is a checked exception that wraps an exception thrown by an invoked method or constructor. 

JSONException

Thrown to indicate a problem with the JSON API. 

JarException

Signals that an error of some sort has occurred while reading from or writing to a JAR file. 

KeyChainException

Thrown on problems accessing the KeyChain. 

KeyCharacterMap.UnavailableException

Thrown by load(int) when a key character map could not be loaded. 

KeyException

This is the basic key exception. 

KeyExpiredException

Indicates that a cryptographic operation failed because the employed key's validity end date is in the past. 

KeyManagementException

This is the general key management exception for all operations dealing with key management. 

KeyNotYetValidException

Indicates that a cryptographic operation failed because the employed key's validity start date is in the future. 

KeyPermanentlyInvalidatedException

Indicates that the key can no longer be used because it has been permanently invalidated. 

KeyStoreException

This is the generic KeyStore exception. 

LSException

Parser or write operations may throw an LSException if the processing is stopped. 

LastOwnerException

This is an exception that is thrown whenever an attempt is made to delete the last owner of an Access Control List. 

LinkageError

Subclasses of LinkageError indicate that a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class. 

LoginException

This is the basic login exception. 

MalformedInputException

Checked exception thrown when an input byte sequence is not legal for given charset, or an input character sequence is not a legal sixteen-bit Unicode sequence. 

MalformedJsonException

Thrown when a reader encounters malformed JSON. 

MalformedParameterizedTypeException

Thrown when a semantically malformed parameterized type is encountered by a reflective method that needs to instantiate it. 

MalformedURLException

Thrown to indicate that a malformed URL has occurred. 

MediaCodec.CodecException

Thrown when an internal codec error occurs. 

MediaCodec.CryptoException

Thrown when a crypto error occurs while queueing a secure input buffer. 

MediaCryptoException

Exception thrown if MediaCrypto object could not be instantiated or if unable to perform an operation on the MediaCrypto object. 

MediaDrm.MediaDrmStateException

Thrown when an unrecoverable failure occurs during a MediaDrm operation. 

MediaDrmException

Base class for MediaDrm exceptions  

MediaDrmResetException

This exception is thrown when the MediaDrm instance has become unusable due to a restart of the mediaserver process. 

MissingFormatArgumentException

Unchecked exception thrown when there is a format specifier which does not have a corresponding argument or if an argument index refers to an argument that does not exist. 

MissingFormatWidthException

Unchecked exception thrown when the format width is required. 

MissingResourceException

Signals that a resource is missing. 

NegativeArraySizeException

Thrown if an application tries to create an array with negative size. 

NetworkErrorException

 

NetworkOnMainThreadException

The exception that is thrown when an application attempts to perform a networking operation on its main thread. 

NoClassDefFoundError

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. 

NoConnectionPendingException

Unchecked exception thrown when the finishConnect method of a SocketChannel is invoked without first successfully invoking its connect method. 

NoRouteToHostException

Signals that an error occurred while attempting to connect a socket to a remote address and port. 

NoSuchAlgorithmException

This exception is thrown when a particular cryptographic algorithm is requested but is not available in the environment. 

NoSuchElementException

Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration. 

NoSuchFieldError

Thrown if an application tries to access or modify a specified field of an object, and that object no longer has that field. 

NoSuchFieldException

Signals that the class doesn't have a field of a specified name. 

NoSuchMethodError

Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method. 

NoSuchMethodException

Thrown when a particular method cannot be found. 

NoSuchPaddingException

This exception is thrown when a particular padding mechanism is requested but is not available in the environment. 

NoSuchPropertyException

Thrown when code requests a Property on a class that does not expose the appropriate method or field. 

NoSuchProviderException

This exception is thrown when a particular security provider is requested but is not available in the environment. 

NonReadableChannelException

Unchecked exception thrown when an attempt is made to read from a channel that was not originally opened for reading. 

NonWritableChannelException

Unchecked exception thrown when an attempt is made to write to a channel that was not originally opened for writing. 

NotActiveException

Thrown when serialization or deserialization is not active. 

NotOwnerException

This is an exception that is thrown whenever the modification of an object (such as an Access Control List) is only allowed to be done by an owner of the object, but the Principal attempting the modification is not an owner. 

NotProvisionedException

Exception thrown when an operation on a MediaDrm object is attempted and the device does not have a certificate. 

NotSerializableException

Thrown when an instance is required to have a Serializable interface. 

NotYetBoundException

Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a server socket channel that is not yet bound. 

NotYetConnectedException

Unchecked exception thrown when an attempt is made to invoke an I/O operation upon a socket channel that is not yet connected. 

NullPointerException

Thrown when an application attempts to use null in a case where an object is required. 

NumberFormatException

Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format. 

ObjectStreamException

Superclass of all exceptions specific to Object Stream classes. 

OperationApplicationException

Thrown when an application of a ContentProviderOperation fails due the specified constraints. 

OperationCanceledException

An exception type that is thrown when an operation in progress is canceled. 

OptionalDataException

Exception indicating the failure of an object read operation due to unread primitive data, or the end of data belonging to a serialized object in the stream. 

OutOfMemoryError

Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector. 

OverlappingFileLockException

Unchecked exception thrown when an attempt is made to acquire a lock on a region of a file that overlaps a region already locked by the same Java virtual machine, or when another thread is already waiting to lock an overlapping region of the same file. 

PackageManager.NameNotFoundException

This exception is thrown when a given package, application, or component name cannot be found. 

ParcelFileDescriptor.FileDescriptorDetachedException

Exception that indicates that the file descriptor was detached. 

ParcelFormatException

The contents of a Parcel (usually during unmarshalling) does not contain the expected data. 

ParseException

Signals that an error has been reached unexpectedly while parsing. 

ParserConfigurationException

Indicates a serious configuration error. 

PatternSyntaxException

Unchecked exception thrown to indicate a syntax error in a regular-expression pattern. 

PendingIntent.CanceledException

Exception thrown when trying to send through a PendingIntent that has been canceled or is otherwise no longer able to execute the request. 

PortUnreachableException

Signals that an ICMP Port Unreachable message has been received on a connected datagram. 

PrivilegedActionException

Legacy security code; do not use. 

ProtocolException

Thrown to indicate that there is an error in the underlying protocol, such as a TCP error. 

ProviderException

A runtime exception for Provider exceptions (such as misconfiguration errors or unrecoverable internal errors), which may be subclassed by Providers to throw specialized, provider-specific runtime errors. 

RSDriverException

Base class for all exceptions thrown by the Android RenderScript  

RSIllegalArgumentException

Base class for all exceptions thrown by the Android RenderScript  

RSInvalidStateException

Base class for all exceptions thrown by the Android RenderScript  

RSRuntimeException

Base class for all exceptions thrown by the Android RenderScript  

ReadOnlyBufferException

Unchecked exception thrown when a content-mutation method such as put or compact is invoked upon a read-only buffer. 

ReceiverCallNotAllowedException

This exception is thrown from registerReceiver(BroadcastReceiver, IntentFilter) and bindService(Intent, ServiceConnection, int) when these methods are being used from an BroadcastReceiver component. 

ReflectiveOperationException

Common superclass of exceptions thrown by reflective operations in core reflection. 

RejectedExecutionException

Exception thrown by an Executor when a task cannot be accepted for execution. 

RemoteException

Parent exception for all Binder remote-invocation errors  

RemoteViews.ActionException

Exception to send when something goes wrong executing an action  

ResourceBusyException

Exception thrown when an operation on a MediaDrm object is attempted and hardware resources are not available, due to being in use. 

Resources.NotFoundException

This exception is thrown by the resource APIs when a requested resource can not be found. 

RuntimeException

RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine. 

SAXException

Encapsulate a general SAX error or warning. 

SAXNotRecognizedException

Exception class for an unrecognized identifier. 

SAXNotSupportedException

Exception class for an unsupported operation. 

SAXParseException

Encapsulate an XML parse error or warning. 

SQLClientInfoException

The subclass of SQLException is thrown when one or more client info properties could not be set on a Connection

SQLDataException

The subclass of SQLException thrown when the SQLState class value is '22', or under vendor-specified conditions. 

SQLException

An exception that provides information on a database access error or other errors. 

SQLFeatureNotSupportedException

The subclass of SQLException thrown when the SQLState class value is '0A' ( the value is 'zero' A). 

SQLIntegrityConstraintViolationException

The subclass of SQLException thrown when the SQLState class value is '23', or under vendor-specified conditions. 

SQLInvalidAuthorizationSpecException

The subclass of SQLException thrown when the SQLState class value is '28', or under vendor-specified conditions. 

SQLNonTransientConnectionException

The subclass of SQLException thrown for the SQLState class value '08', or under vendor-specified conditions. 

SQLNonTransientException

The subclass of SQLException thrown when an instance where a retry of the same operation would fail unless the cause of the SQLException is corrected. 

SQLRecoverableException

The subclass of SQLException thrown in situations where a previously failed operation might be able to succeed if the application performs some recovery steps and retries the entire transaction or in the case of a distributed transaction, the transaction branch. 

SQLSyntaxErrorException

The subclass of SQLException thrown when the SQLState class value is '42', or under vendor-specified conditions. 

SQLTimeoutException

The subclass of SQLException thrown when the timeout specified by Statement has expired. 

SQLTransactionRollbackException

The subclass of SQLException thrown when the SQLState class value is '40', or under vendor-specified conditions. 

SQLTransientConnectionException

The subclass of SQLException for the SQLState class value '08', or under vendor-specified conditions. 

SQLTransientException

The subclass of SQLException is thrown in situations where a previoulsy failed operation might be able to succeed when the operation is retried without any intervention by application-level functionality. 

SQLWarning

An exception that provides information on database access warnings. 

SQLiteAbortException

An exception that indicates that the SQLite program was aborted. 

SQLiteAccessPermException

This exception class is used when sqlite can't access the database file due to lack of permissions on the file. 

SQLiteBindOrColumnIndexOutOfRangeException

Thrown if the the bind or column parameter index is out of range  

SQLiteBlobTooBigException

 

SQLiteCantOpenDatabaseException

 

SQLiteConstraintException

An exception that indicates that an integrity constraint was violated. 

SQLiteDatabaseCorruptException

An exception that indicates that the SQLite database file is corrupt. 

SQLiteDatabaseLockedException

Thrown if the database engine was unable to acquire the database locks it needs to do its job. 

SQLiteDatatypeMismatchException

 

SQLiteDiskIOException

An exception that indicates that an IO error occured while accessing the SQLite database file. 

SQLiteDoneException

An exception that indicates that the SQLite program is done. 

SQLiteException

A SQLite exception that indicates there was an error with SQL parsing or execution. 

SQLiteFullException

An exception that indicates that the SQLite database is full. 

SQLiteMisuseException

This error can occur if the application creates a SQLiteStatement object and allows multiple threads in the application use it at the same time. 

SQLiteOutOfMemoryException

 

SQLiteReadOnlyDatabaseException

 

SQLiteTableLockedException

 

SSLException

Indicates some kind of error detected by an SSL subsystem. 

SSLHandshakeException

Indicates that the client and server could not negotiate the desired level of security. 

SSLKeyException

Reports a bad SSL key. 

SSLPeerUnverifiedException

Indicates that the peer's identity has not been verified. 

SSLProtocolException

Reports an error in the operation of the SSL protocol. 

SecurityException

Thrown by the security manager to indicate a security violation. 

ServiceConfigurationError

Error thrown when something goes wrong while loading a service provider. 

Settings.SettingNotFoundException

 

ShortBufferException

This exception is thrown when an output buffer provided by the user is too short to hold the operation result. 

SignatureException

This is the generic Signature exception. 

SipException

Indicates a general SIP-related exception. 

SocketException

Thrown to indicate that there is an error creating or accessing a Socket. 

SocketTimeoutException

Signals that a timeout has occurred on a socket read or accept. 

StackOverflowError

Thrown when a stack overflow occurs because an application recurses too deeply. 

StaleDataException

This exception is thrown when a Cursor contains stale data and must be requeried before being used again. 

StreamCorruptedException

Thrown when control information that was read from an object stream violates internal consistency checks. 

StringIndexOutOfBoundsException

Thrown by String methods to indicate that an index is either negative or greater than the size of the string. 

StringPrepParseException

Exception that signals an error has occurred while parsing the input to StringPrep or IDNA. 

Surface.OutOfResourcesException

Exception thrown when a Canvas couldn't be locked with lockCanvas(Rect), or when a SurfaceTexture could not successfully be allocated. 

SurfaceHolder.BadSurfaceTypeException

Exception that is thrown from lockCanvas() when called on a Surface whose type is SURFACE_TYPE_PUSH_BUFFERS. 

SurfaceTexture.OutOfResourcesException

This class was deprecated in API level 19. No longer thrown. Surface.OutOfResourcesException is used instead.  

SyncFailedException

Signals that a sync operation has failed. 

TagLostException

 

ThreadDeath

An instance of ThreadDeath is thrown in the victim thread when the (deprecated) stop() method is invoked. 

TimeFormatException

 

TimeoutException

Exception thrown when a blocking operation times out. 

TooManyListenersException

The TooManyListenersException Exception is used as part of the Java Event model to annotate and implement a unicast special case of a multicast Event Source. 

TransactionTooLargeException

The Binder transaction failed because it was too large. 

TransformerConfigurationException

Indicates a serious configuration error. 

TransformerException

This class specifies an exceptional condition that occurred during the transformation process. 

TransformerFactoryConfigurationError

Thrown when a problem with configuration with the Transformer Factories exists. 

TypeNotPresentException

Thrown when an application tries to access a type using a string representing the type's name, but no definition for the type with the specified name can be found. 

URISyntaxException

Checked exception thrown to indicate that a string could not be parsed as a URI reference. 

UTFDataFormatException

Signals that a malformed string in modified UTF-8 format has been read in a data input stream or by any class that implements the data input interface. 

UncheckedIOException

Wraps an IOException with an unchecked exception. 

UndeclaredThrowableException

Thrown by a method invocation on a proxy instance if its invocation handler's invokemethod throws a checked exception (a Throwable that is not assignable to RuntimeException or Error) that is not assignable to any of the exception types declared in the throws clause of the method that was invoked on the proxy instance and dispatched to the invocation handler. 

UnknownError

Thrown when an unknown but serious exception has occurred in the Java Virtual Machine. 

UnknownFormatConversionException

Unchecked exception thrown when an unknown conversion is given. 

UnknownFormatFlagsException

Unchecked exception thrown when an unknown flag is given. 

UnknownHostException

Thrown to indicate that the IP address of a host could not be determined. 

UnknownServiceException

Thrown to indicate that an unknown service exception has occurred. 

UnmappableCharacterException

Checked exception thrown when an input character (or byte) sequence is valid but cannot be mapped to an output byte (or character) sequence. 

UnrecoverableEntryException

This exception is thrown if an entry in the keystore cannot be recovered. 

UnrecoverableKeyException

This exception is thrown if a key in the keystore cannot be recovered. 

UnresolvedAddressException

Unchecked exception thrown when an attempt is made to invoke a network operation upon an unresolved socket address. 

UnsatisfiedLinkError

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native

UnsupportedAddressTypeException

Unchecked exception thrown when an attempt is made to bind or connect to a socket address of a type that is not supported. 

UnsupportedCallbackException

Signals that a CallbackHandler does not recognize a particular Callback

UnsupportedCharsetException

Unchecked exception thrown when no support is available for a requested charset. 

UnsupportedClassVersionError

Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported. 

UnsupportedEncodingException

The Character Encoding is not supported. 

UnsupportedOperationException

Thrown to indicate that the requested operation is not supported. 

UnsupportedSchemeException

Exception thrown when an attempt is made to construct a MediaDrm object using a crypto scheme UUID that is not supported by the device  

UserNotAuthenticatedException

Indicates that a cryptographic operation could not be performed because the user has not been authenticated recently enough. 

VerifyError

Thrown when the "verifier" detects that a class file, though well formed, contains some sort of internal inconsistency or security problem. 

VirtualMachineError

Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating. 

WindowManager.BadTokenException

Exception that is thrown when trying to add view whose WindowManager.LayoutParamstoken is invalid. 

WindowManager.InvalidDisplayException

Exception that is thrown when calling addView(View, ViewGroup.LayoutParams) to a secondary display that cannot be found. 

WriteAbortedException

Signals that one of the ObjectStreamExceptions was thrown during a write operation. 

XPathException

XPathException represents a generic XPath exception. 

XPathExpressionException

XPathExpressionException represents an error in an XPath expression. 

XPathFactoryConfigurationException

XPathFactoryConfigurationException represents a configuration error in a XPathFactory environment. 

XPathFunctionException

XPathFunctionException represents an error with an XPath function. 

XmlPullParserException

This exception is thrown to signal XML Pull Parser related faults. 

ZipError

Signals that an unrecoverable error has occurred. 

ZipException

Signals that a Zip exception of some sort has occurred. 

0 0
原创粉丝点击