1. 启动eclipse,一直停留在进度条处
eclipse编译工程时,电脑死机。重启后eclipse启动不起来,停在启动界面不动了。
解决方法,清空eclipse安装目录下configuration文件夹中除了config.ini的所有东西,这里好像是eclipse的缓存。然后就可以正常启动了。
但是,当重新切换到之前正在编译的工程的workspace时,还是无法打开。这可能是之前没编译完成突然死机,致使某些程序错误所导致的。由于我之前有备份,就把出错的那个workspace删去,然后重建了一个。做好备份还是很重要的。
-----------------------------------------------------------------------------
2. Re-installation failed due to different application signatures.
运行程序,出现以下错误
[2012-07-24 13:56:15 - Test]Installing Test.apk...
[2012-07-24 13:56:16 - Test]Re-installation failed due to different application signatures.
[2012-07-24 13:56:16 - Test] You mustperform a full uninstall of the application. WARNING: This will remove theapplication data!
[2012-07-24 13:56:16 - Test] Pleaseexecute 'adb uninstall com.test' in a shell.
[2012-07-24 13:56:16 - Test] Launch canceled!
解决方法:找到保护adb.exe的文件夹,
a. 进入命令行,
b. 进入保护adb.exe的文件夹有的在tools文件夹下面(有的在F:\Android\android-sdk-windows\platform-tools下面),
c. 输入 adb uninstall包名,例如我的是adb uninstall com.test
-----------------------------------------------------------------------------
3. android imageview 多余空白
发现如果图片被缩小尺寸后,图片周围会有多余的空白,搜索得到解决办法:
<ImageView
(…)
android:adjustViewBounds=”true” />
-----------------------------------------------------------------------------
4.保持屏幕一直亮
Windowwindow = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-----------------------------------------------------------------------------
5.android.view.WindowManager$BadTokenException: Unable to add window
// 退出主程序dialog public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { dialog(); return false; } return super.onKeyDown(keyCode, event); } protected void dialog() { AlertDialog.Builder builder = new Builder(FindwebActivity.this); builder.setMessage("确定要退出心愿吗?"); builder.setTitle("提示"); builder.setPositiveButton("确认", new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); AgentApp.getInstance().onTerminate(); } }); builder.setNegativeButton("取消", new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
改成AlertDialog.Builder builder = new Builder(FindwebActivity.this);
即可AlertDialog.Builder builder = new Builder(getParent());
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
6. Android WindowManager$BadTokenException异常
ERROR/AndroidRuntime(10104): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@45a58ee0 is not valid; is your activity running?
原因分析:
因为new对话框的时候,参数content 指定成了this,即指向当前子Activity的content。但子Activity是动态创建的,不能保证一直存在。其父Activity的content是稳定存在的,所以有下面的解决办法。
解决办法:
将content替换为getParent()即可。