(六)项目实战之异常问题

项目实战之异常问题

1.异常信息
Attempted to access a cursor after it has been closed.
  • [解決方法] cursor 已经关闭却再次使用问题,判断cursor 是否关闭
2.异常信息
com.android.tools.r8.utils.AbortException
  • [解決方法] 修改gradle 版本号 =>com.android.tools.build:gradle:xxxx
3.异常信息
Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
  • [解決方法 再把其他不报错的项目gradle文件复制过来再重新运行就可以了
4.异常信息
ERROR: Unable to find method 'org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
  • [解決方法] 关闭Android studio,删除报错项目的 .gradle 和gradle 文件夹再把其他不报错的项目gradle文件复制过来再重新运行就可以了
5.异常信息
Invocation failed Unexpected Response from Server:  Unauthorized
  • [解決方法] AndroidStudio -> Preferences -> Git -> SSH Executable and changed from Native to Built-in and it started working.
6.异常信息(阿里服务,其他开发人员正常,自己异常时)
#24402 java.lang.ClassNotFoundException
Didn't find class "com.ta.utdid2.device.UTDevice" on path: DexPathList[[zip file "/data/app/com.zczy.cargo_owner-wf370Z9INZn6WuQ3DTR0HQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.zczy.cargo_owner-wf370Z9INZn6WuQ3DTR0HQ==/lib/arm, /data/app/com.zczy.cargo_owner-wf370Z9INZn6WuQ3DTR0HQ==/base.apk!/lib/armeabi, /system/lib, /system/vendor/lib]] 
com.alibaba.sdk.android.beacon.b.a(Unknown Source:38)
  • [解決方法] AndroidStudio -> Invalidate and Restart
7.异常信息
Fragment must be a public static class to be properly recreated from instance state
  • [解決方法] 把fragment定义独立类文件,不要用匿名内部类的方式
8.异常信息
java.lang.IllegalStateException

Can not perform this action after onSaveInstanceState
android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2053)
  • [解決方法] onSaveInstanceState方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就是把commit()方法替换成 commitAllowingStateLoss()
9.异常信息
Unable to start service Intent { cmp=com.xxx.xxxx/com.xxx.xxx.LocationService (has extras) }: Unable to launch app com.xxxx.xxxxx/10110 for service Intent { cmp=com.xxx.xxx/com.xxx.LocationService }: process is bad
com.xxx.xxx.LocationService.startLocationSever(LocationService.java:88)
  • [解決方法] .manifest中未声明service的权限,这种情况下需要在manifest中声明service,由于部分手机自动熄屏一段时间后,会启用系统自带的电量优化管理,禁止一切自启动的APP(用户设置的自启动白名单除外),需要try catch
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值