Crash-fix-1:PhoneWindow$DecorView{29b8ae38 V.E..... R.....I. 0,0-1160,607} not attached to window ma
最近开始对APP上的Crash进行对应,发现有好多常见的问题,同一个问题在多个APP都类似的出现了,这里记录下这些常见的错误。
crash log:
java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{29b8ae38 V.E..... R.....I. 0,0-1160,607} not attached to window manager
at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:370)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:299)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.app.Dialog.dismissDialog(Dialog.java:329)
at android.app.Dialog.dismiss(Dialog.java:312)
设备信息:系统版本:4.4.2
根据错误log可以看出基本又是在Activity的生命周期上出现的问题,Activity已经销毁了,再调用Dialog.dismiss()方法。
经过代码排查,定位到了问题:
handler.postDelayed(dismissDialogRunnable,1000);
在Activity已经finish了,延迟1s后执行dismissDialogRunnable内对Dialog进行销毁。
知道问题了,就很好解决了,取消延迟,在Activity的OnDestory方法中销毁Dialog。
追根究底,下载了对应系统的的源码查看:
首先:Dialog.dismiss()方法:
在dismissDialog方法中调用了WindowManager的removeViewImmediate方法:
@Override
public void removeViewImmediate(View view) {
mGlobal.removeView(view, true);
}
mGlobal是WindowManagerGlobal实例对象,继续深入:
public void removeView(View view, boolean immediate) {
if (view == null) {
throw new IllegalArgumentException("view must not be null");
}
synchronized (mLock) {
int index = findViewLocked(view, true);
View curView = mRoots.get(index).getView();
removeViewLocked(index, immediate);
if (curView == view) {
return;
}
throw new IllegalStateException("Calling with view " + view
+ " but the ViewAncestor is attached to " + curView);
}
}
private int findViewLocked(View view, boolean required) {
final int index = mViews.indexOf(view);
if (required && index < 0) {
throw new IllegalArgumentException("View=" + view + " not attached to window manager");
}
return index;
}
在WindowManagerGlobal.findViewLocked中,会获取Dialog所在Window.decorView的位置,如果获取不到,则抛出异常。
至此,该问题发生的原因已经非常明了了。
Crash-fix-1:PhoneWindow$DecorView{29b8ae38 V.E..... R.....I. 0,0-1160,607} not attached to window ma的更多相关文章
- SQL_Server_2008定期自动备份详细图解
SQL_Server_2008定期自动备份详细图解 设置自动数据库的定期备份计划. http://wenku.baidu.com/link?url=Tu ...
- 关于dialog引起的 java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView not attached to window manager 错误的分析
在跑Monkey测试的时候出现了一个比较特别的问题,先来看看Log: // CRASH: com.meizu.media.painter (pid 12491) // Short Msg: java. ...
- decorview that was originally added here or java.lang.IllegalArgumentException: View not attached to window manager
使用Dialog的时候,没少出现下面这两个报错 12-11 17:47:49.776: E/WindowManager(11461): android.view.WindowLeaked: Activ ...
- View not attached to window manager crash 的解决办法
View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...
- 仅仅需手动添加一行代码就可以让Laravel4执行在SAE (v. 1.0.0)
Github:https://github.com/chariothy/laravel4-sae (已更新至v1.1.0) laravel4-sae (v. 1.0.0) 仅仅需手动添加一行代码就可以 ...
- Fix Python 3 on Windows error Microsoft Visual C++ 14.0 is required
Fix Python 3 on Windows error Microsoft Visual C++ 14.0 is required Fix the error for Python 3.6 and ...
- windows server 2008 r2 启用索引(转)
08r2的“windows search”服务默认是不安装的,要想启用索引执行下列步骤: 1.打开“服务器管理”——选中“角色”——右边选中“添加角色”——勾选“文件服务”. 2. ...
- BayaiM__ORACLE之ASM概念 --V 1.0.0
BayaiM__ORACLE之ASM概念 --V 1.0.0 -------------------------------------- ...
- ORA-04031 With Leak in "OBJ STAT MEMO" Allocations Seen in V$SGASTAT on 10.2.0.5 (文档 ID 1350050.1)
APPLIES TO: Oracle Server - Enterprise Edition - Version: 10.2.0.5<max_ver> and later [Relea ...
随机推荐
- 单图像三维重建、2D到3D风格迁移和3D DeepDream
作者:Longway Date:2020-04-25 来源:单图像三维重建.2D到3D风格迁移和3D DeepDream 项目网址:http://hiroharu-kato.com/projects_ ...
- curl book
curl是利用URL语法在命令行方式下工作的开源文件传输工具.它被广泛应用在Unix.多种Linux发行版中,并且有DOS和Win32.Win64下的移植版本. 官方地址 man page 下载页面, ...
- Java中Date时间类
Date:表示特定的瞬间,精确到毫秒. 构造方法: Date():根据当前的默认毫秒值创建日期对象 Date(long date):根据给定的毫秒值创建日期对象 public static void ...
- 云开发网站托管悄悄上线了 Next.js 的支持
我们知道部署web应用程序的最佳方式是作为静态HTML应用程序,因为他对搜索引擎很友好,速度快等等,这对我们写个人博客这样的小型网站无异于非常nice.如果你的应用可以作为静态HTML,那么可以试试N ...
- 关于foreach总是报错invalid param等问题
原因为被foreach的数组可能为空,则会报错,只需做好容错即可,例如 if ( !empty( $arr ) ) { foreach ( $arr as $k => $v ) { } }
- history of program atan2(y,x)和pow(x,y)
编年史 1951 – Regional Assembly Language 1952 – Autocode 1954 – IPL (LISP语言的祖先) 1955 – FLOW-MATIC (COBO ...
- dhcpd.conf(5) - Linux man page
http://linux.die.net/man/5/dhcpd.conf Name dhcpd.conf - dhcpd configuration file Description The d ...
- OpenStack 删除instance 和其附加的volumes
在openstack里面有时候删除instance时,volume无法跟着删除,可以自己编写脚本来实现, 脚本代码如下: #!/bin/bash for i in $(cat /root/host-d ...
- [svc]frp内网穿透
什么是穿透 可以任意暴漏内网任何服务,加入你在你的办公网络有台pc,可以上网就可以了, 你可以在你电脑上安装各类服务器, 暴漏如80 22等端口, 注意 这可以暴漏到公网哦, 在出口不做任何nat情况 ...
- P1522 牛的旅行 Cow Tours(floyd)
题目描述 农民 John的农场里有很多牧区.有的路径连接一些特定的牧区.一片所有连通的牧区称为一个牧场.但是就目前而言,你能看到至少有两个牧区通过任何路径都不连通.这样,Farmer John就有多个 ...