50个Android开发中常见的异常崩溃情况

这篇文章列举了Android应用开发中可能遇到的50种常见异常,包括NullPointerException、OutOfMemoryError、SQLite数据库异常、网络异常如SocketException和SSLException,以及JSON解析等编程错误。这些异常通常会导致应用崩溃,对开发者识别和修复问题至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以下是50个Android开发中常见的异常崩溃情况和对应的异常日志:

NullPointerException:指针为空异常

java.lang.NullPointerException: Attempt to invoke virtual method ‘…’ on a null object reference
ClassCastException:类型转换异常

java.lang.ClassCastException: … cannot be cast to …
IllegalArgumentException:非法参数异常

java.lang.IllegalArgumentException: … is not a valid argument
IllegalStateException:非法状态异常

java.lang.IllegalStateException: … is not in a valid state
IndexOutOfBoundsException:越界异常

java.lang.IndexOutOfBoundsException: Index … out of bounds for length …
OutOfMemoryError:内存溢出错误

java.lang.OutOfMemoryError: Failed to allocate a … byte allocation with … free bytes and …MB until OOM, target footprint …MB, growth limit …MB
NoSuchMethodError:方法不存在错误

java.lang.NoSuchMethodError: … method not found
ArithmeticException:算术异常

java.lang.ArithmeticException: … / by zero
SecurityException:安全异常

java.lang.SecurityException: … not allowed to perform operation
NetworkOnMainThreadException:主线程网络异常

android.os.NetworkOnMainThreadException
InflateException:布局解析异常

android.view.InflateException: Binary XML file line #…: Error inflating class …
ResourcesNotFoundException:资源未找到异常

android.content.res.Resources$NotFoundException: Resource ID #… not found
SQLiteDatabaseLockedException:SQLite数据库锁定异常

android.database.sqlite.SQLiteDatabaseLockedException: database is locked
SQLiteException:SQLite数据库异常

android.database.sqlite.SQLiteException: … error code …
StaleDataException:数据过期异常

android.database.StaleDataException: Attempted to access a cursor after it has been closed.
VerificationError:验证错误

java.lang.VerifyError: … access … from incompatible class …
AssertionError:断言错误

java.lang.AssertionError: … assertion failed
NoSuchAlgorithmException:加密算法不存在异常

java.security.NoSuchAlgorithmException: … algorithm not available
SocketException:Socket异常

java.net.SocketException: … failed: ECONNREFUSED (Connection refused)
SSLException:SSL异常

javax.net.ssl.SSLException: … SSL handshake aborted
FileNotFoundException:文件未找到异常

java.io.FileNotFoundException: … (No such file or directory)
IOException:IO异常

java.io.IOException: … (Connection timed out)
ParseException:解析异常

java.text.ParseException: Unparseable date: “…”
JSONException:JSON解析异常

org.json.JSONException: … at character …
SAXException:SAX解析异常

org.xml.sax.SAXException: … at line …
NumberFormatException:数字格式化异常

java.lang.NumberFormatException: For input string: “…”
IllegalStateException:线程状态异常

java.lang.IllegalStateException: Cannot execute task: the task is already running.
ConcurrentModificationException:并发修改异常

java.util.ConcurrentModificationException: … (java.util.ConcurrentModificationException)
UnsupportedOperationException:不支持的操作异常

java.lang.UnsupportedOperationException: … not supported
InterruptedException:线程中断异常

java.lang.InterruptedException: sleep interrupted
RuntimePermission:权限异常

java.lang.RuntimePermission: … permission required
AuthenticationException:认证异常

org.apache.http.client.ClientProtocolException: … (authentication challenge)
FileNotFoundException:未找到文件异常

java.io.FileNotFoundException: … File not found.
UnsupportedOperationException:不支持的操作异常

java.lang.UnsupportedOperationException: … not supported
EOFException:文件结尾异常

java.io.EOFException: … end of file reached
ConnectException:连接异常

java.net.ConnectException: … Connection refused
SocketTimeoutException:Socket超时异常

java.net.SocketTimeoutException: … Read timed out
JNIException:Java本机接口异常

java.lang.reflect.InvocationTargetException: JNI Exception: …
NoSuchProviderException:提供程序不存在异常

java.security.NoSuchProviderException: Provider … not found
Surface.OutOfResourcesException:Surface资源耗尽异常

android.view.Surface$OutOfResourcesException: … (Surface with no valid EGLContext)
WindowManager.BadTokenException:无效的Window Token异常

android.view.WindowManager$BadTokenException: … is not valid; is your activity running?
TimeoutException:超时异常

java.util.concurrent.TimeoutException: … timeout
SSLHandshakeException:SSL握手异常

javax.net.ssl.SSLHandshakeException: … SSL handshake aborted
SAXParseException:SAX解析异常

org.xml.sax.SAXParseException: … at line …
IllegalStateException:未知的Bundle标记异常

java.lang.IllegalStateException: Unknown Bundle Marker at position …: …
IllegalArgumentException:传递了错误的方位坐标

java.lang.IllegalArgumentException: Point (?, ?) must be in the range ? <= x <= ? and ? <= y <= ?
SQLiteReadOnlyDatabaseException:SQLite只读数据库异常

android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write to a readonly database
SQLException:SQL异常

java.sql.SQLException: … SQL exception
ZipException:压缩文件异常

java.util.zip.ZipException: … Not in GZIP format
DifferentKeyException:与此密钥不相关的密钥异常

java.security.spec.InvalidKeySpecException: Inappropriate key specification: Different key pair generated for given keyUsageInfo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a老李a

解决问题没 解决了就安排一波

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值