Android调试异常汇总(一)

1、
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@8
错误源: progressDialog=CustomProgressDialog.createDialog(context),ProgressDialog只能显示在Activity中

而不能显示在Context上下文上,所以更换为Activity的对象就解决。


2、

Error:Execution failed for task ':myapp:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 
错误源:libs下的jar包冲突了,重点排查android-support-v13冲突,解决办法十分简单,首先在module的build.gradle文件中,删除引用的语句,,如下:
compile files('libs/nineoldandroids-2.4.0.jar')然后再删除你引用的包。


3、

安装Eclipse时出现failed to load the jni shared library
错误源:说明JDK的Eclipse的位数不一样,重新下载适合你电脑的Eclipse


4、

Debug运行Button点击时间时,Break Point显示红叉且不执行点击事件,红叉显示no executable code found at line
错误源:最先查找实现Onclick方法后是不是没有给Button添加点击事件实现,如 locationButton.setOnClickListener(this);


5、

 Activity com.beidougd.bdg.activity.FragmentMainActivity has leaked IntentReceiver com.beidougd.bdg.activity.MainTabHomeNew$DeviceListReceiver@53c34078 that was originally registered here. Are you missing a call to unregisterReceiver()?
错误源1:使用的是Fragment, 后来在重载Fragment的onDetach:

    @Override  
    public void onDetach() {  
        super.onDetach();  
        if(viewFlipper!=null){  
            //防止android.app.IntentReceiverLeaked  
            viewFlipper.stopFlipping();  
        }  
    }  
即可解决。

错误源2:没有在注册广播后,取消注册广播。


6、

.targetTabLabel加入TabHost中时会出现java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.的异常
错误源:
tabhost = getTabHost();  
RelativeLayout tempLayout = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.mytab, null);  
TextView targetTabLabel = (TextView) tempLayout.findViewById(R.id.tab_text);  
targetTabLabel.setText("TAB 1");  
tempLayout.removeAllViews();  
tabhost.addTab(tabhost.newTabSpec("1").setIndicator(targetTabLabel).setContent(R.id.text1));
要对tempLayout使用removeAllViews()。

7、

java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 4, found: 12 Pager id: 
com.beidougd.bdgc:id/viewPager Pager class: class android.support.v4.view.ViewPager Problematic adapter: class com.beidougd.bdg.util.SlideShowView$MyPagerAdapter

错误源:在快速加载网络数据时,由于获得的数据还没有适配在Adapter上,就快速切换Activity,处理方法是将此异常捕获,因为这种双手快速切换Activity的实例属于不正常现象,所以,我采用try{}Catch(Expection e){}





你可能感兴趣的:(Android调试异常汇总(一))