Android开发常见错误汇总

【错误信息】 
[2011-01-19 16:39:10 - ApiDemos] WARNING: Application does not specify an API level requirement!
[2011-01-19 16:39:10 - ApiDemos] Device API version is 8 (Android 2.2)
缘由:
不影响正常运行。在AndroidManifest.xml文件中没有加API的版本号,在<manifest> </manifest> 之间加<uses-sdk android:minSdkVersion="3"></uses-sdk>
[2011-01-19 16:55:04 - ApiDemos] Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
[2011-01-19 16:55:04 - ApiDemos] Please check logcat output for more details.
[2011-01-19 16:55:05 - ApiDemos] Launch canceled!
该设备没有足够的存储空间来安装应用程序,
【错误信息】
[2011-02-18 11:46:53] Failed to push selection: Is a directory
缘由:
原先目录已经有pkg_3.apk的文件夹,再copy一个pkg_3.apk安装文件时出现问题,解决办法,先删除掉pkg_3.apk的文件夹
[2011-03-04 09:25:12 - ActivityMain]: Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg1/apache/commons/codec/net/RFC1522Codec;
[2011-03-04 09:25:12 - ActivityMain]: Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2011-03-04 09:25:12 - ActivityMain]: Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
.....

[2011-03-04 09:25:12 - ActivityMain]: Dx1 error; aborting
[2011-03-04 09:25:12 - ActivityMain] Conversion to Dalvik format failed with error 1

缘由:
【错误信息】
启动Eclipse时出现:
this android sdk requires android developer toolkit version 10.0.0 or above.
current version is 8.0.1.v201012062107-82219.
please update adt to the latest version

缘由:
Eclipse的Android开发插件版本太低,应该下载ADT-10.0.0,而且
1. 启动 Eclipse, 而后进入 Help > Install New Software.
2. 在 Available Software 对话框里,点击 Add....
【错误信息】
[2011-03-09 15:21:34 - Info] Failed to install Info.apk on device '?': Unable to open sync connection!
[2011-03-09 15:21:34 - Info] java.io.IOException: Unable to open sync connection!
[2011-03-09 15:21:34 - Info] Launch canceled!
缘由:
关闭模拟器和eclipse,执行adb kill-server命令,而后重试一下
【错误信息】
调用Webservice时出现
java.net.SocketException: Permission denied (maybe missing INTERNET permission)
缘由:
须要访问到网络,因此,在AndroidManifest.xml中,须要进行以下配置: 
<uses-permission android:name="android.permission.INTERNET" />
【错误信息】
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <{http://schemas.xmlsoap.org/wsdl/}wsdl:definitions targetNamespace='http://bo.webservice.nqbx.nq.com'>@2:603 injava.io.InputStreamReader@44a3a7b0)
缘由有多是如下2个之一:
1)Webservice服务器的Soap版本为1.0,因此客户端指定
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
VER11改成VER10
2)String serviceUrl = "http://200.200.200.11:10000/nqbx/service/InqBxWebService?wsdl";
Url指的是你的webservice的地址.通常都是以***.wsdl或者***.?wsdl结束的...可是.须要注意的是..要去掉后面的.wsdl或者.?wsdl
【错误信息】
在新的线程中 public class HttpThread extends Thread {...}
增长一个弹出窗体:java

new AlertDialog.Builder(this).setTitle("数据加载失败").setMessage("请检查网络链接状况")          

 .setPositiveButton("OK", new DialogInterface.OnClickListener(){            

public void onClick(DialogInterface dialoginterface, int i)            

{            

}            

}).show(); 

 
缘由及解决办法:
//不能在线程中操做UI界面
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
修改后:android

new AlertDialog.Builder(com.nantsing.infoquery.chuanbo_detail.this).setTitle("数据加载失败").setMessage("请检查网络链接状况")           
.setPositiveButton("OK", new DialogInterface.OnClickListener(){           
 public void onClick(DialogInterface dialoginterface, int i)           
 {           
 }


【错误信息】
The constructor AlertDialog.Builder(chuanbo_detail.HttpThread) is undefined 
缘由及解决办法:
在UI主线程以外是没法对UI组件进行控制的。由于你必须在新线程任务完成以后利用各类方法先UI主线程发送消息通知任务完成从而来显示各类提示消息。
线程间通讯方法有多种,经常使用的是用handler来传递消息。

以下:
线程中构造消息:
//构造消息Message message = handle.obtainMessage();Bundle b = new Bundle();b.putString("tag", "1");message.setData(b);handle.sendMessage(message); 
另外自定义消息:  web

 /** * 捕获消息队列 fubin.pan 2011-04-02 */
Handler handler = new Handler() {
public void handleMessage(Message m) 
{
if (!m.getData().getString("tag").equals("1"))
{                            ...}
else{
new AlertDialog.Builder(chuanbo_detail.this).setTitle("数据加载失败").setMessage("请检查网络链接状况!")                
.setPositiveButton("OK", new DialogInterface.OnClickListener(){                        
public void onClick(DialogInterface dialoginterface, int i)                        {                        }          
}).show();
}
}
};


【错误信息】 
android低版本工程(如1.5)放到高版本环境中(如2.2)可能会上述错误,解决方法以下:
1。 若是不修改android sdk版本,则使用project clean 命令做用于某工程便可。
       (该处理方式只是在高版本中兼容了低版本工程,未真正意义上的升级)
2。 若是修改android sdk版本,则须要如下几个步骤:
       1)修改SDK
             选择工程,build path --> configure build path ---> library 删除引用的低版本SDK,
             而后add External JARs,选择高版本SDK,OK,保存
        2)修改classpath文件 
             该文件可能存在该项: <classpathentry kind="lib"   path ="你所指定的高版本的地址"
             把她修改为<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" />
        3) 修改AndroidManifest.xml
             在AndroidManifest.xml文件中,application标签后添加<uses-sdk android:minSdkVersion="3"></uses-sdk>
        4) 修改default.properties(很重要)
              该文件最后一行(前面没用#的)target=android-3 该成target=android-8,保存。
        再看看你的工程和新建的android 2.2的工程结构就同样了。

【错误信息】
在线程debug(运行没有问题)时调用Webservice时出现:
'JDI thread evaluations' has encountered a problem
Exception processing async thread queue

Exception processing async thread queue
JDI thread evaluations

缘由及解决办法:
与运行无关的错误,关掉'expressions'视图就能够了
【错误信息】
打开开源项目JavaEye Android client时出错
http://javaeye-android-client.googlecode.com/svn/trunk/
这是 JavaEye 网站基于 Android 平台的客户端软件,可用以阅读动静、帖子、闲谈, 收躲, RSS 等功用。
[2011-04-19 10:55:11 - JavaEye Android Client] Project has no default.properties file! Edit the project properties to set one.
缘由及解决办法:
遇到这种状况,能够建立一个default.properties文件,若是建立以后仍是有错误,那么delete这个project,从新import。
编辑default.properties 以后,通常会自动建立 gen 目录, 若是没有,也可尝试手工建立。
✿Adroid Adapter ADB Interface 严重错误
今天在配置完Eclipse和Android SDK开发环境以后,想用华为C8500手机经过USB链接电脑,并在手机上去调试,但莫名其妙出现Adroid Adapter ADB Interface 安装严重错误,在豌豆荚手机精灵安装驱动的时候,也出现这个错误,后面也莫名奇妙的多装几回就行了,还没找到什么缘由。
【错误信息】
用手机调试运行出现:
ActivityManager: Warning: Activity not started, its current task has been brought to the front
缘由及解决办法:
该手机已经启动了相同名字的应用,关闭以后再试!
【错误信息】
最近(2012-04-05)在打开SDK Manager.exe,更新SDK时,会出现以下错误:

Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml, 
reason: Connection timed out: connect
缘由及解决办法:
dl-ssl.google.com在大陆封掉了
解决方法就是修改C:\Windows\System32\drivers\etc\hosts文件。添加一行:
74.125.237.1       dl-ssl.google.com 
保存,从新启动SDK Manager.exe
【错误信息】
[2012-04-08 17:42:24 - JavaEye Android Client] ------------------------------
[2012-04-08 17:42:24 - JavaEye Android Client] Android Launch!
[2012-04-08 17:42:24 - JavaEye Android Client] The connection to adb is down, and a severe error has occured.
[2012-04-08 17:42:24 - JavaEye Android Client] You must restart adb and Eclipse.
[2012-04-08 17:42:24 - JavaEye Android Client] Please ensure that adb is correctly located at 'C:\android\android-sdk-windows\platform-tools\adb.exe' and can be executed.
缘由及解决办法:
查看任务管理器,关闭全部adb.exe
重启eclipse便可
【错误信息】
更新SDK时错误信息:
Site Authentication
Please login to the following ......

缘由及解决办法:
Cancel跳过提示
【错误信息】
打开Eclipse 提示安装ADT 17

缘由及解决办法:
最新的Android SDK只能安装ADT 17.0.0
可用的下载地址:http://download.csdn.net/detail/merrido/4169460,
这里可不能用常规方法安装这个 ADT 17.0.0.zip 文件, 首先得解压这个文件,将里面的文件夹覆盖掉Eclipse安装目录下的文件夹。
而后再用Help-> install new software->Add -> Name: ADT   Archive:选择ADT 17.0.0.zip 
【错误信息】
安装ADT 17.0.0时,提示:
Your original request has been modified.
  "Android DDMS" is already installed, so an update will be performed instead.
  "Android Development Tools" is already installed, so an update will be performed instead.
  "Android Hierarchy Viewer" is already installed, so an update will be performed instead.
  "Android Traceview" is already installed, so an update will be performed instead.
Cannot complete the install because one or more required items could not be found.
  Software being installed: Android Development Tools 17.0.0.v201203161636-291853 (com.android.ide.eclipse.adt.feature.group 17.0.0.v201203161636-291853)
  Missing requirement: Android Development Tools 17.0.0.v201203161636-291853 (com.android.ide.eclipse.adt.feature.group 17.0.0.v201203161636-291853) requires 'org.eclipse.core.runtime 3.6.0' but it could not be found
缘由及解决办法:
【错误信息】
Updates ADT 17.0.0时提示:
Cannot complete the install because one or more required items could not be found.
  Software being installed: Android Development Tools 17.0.0.v201203161636-291853 (com.android.ide.eclipse.adt.feature.group 17.0.0.v201203161636-291853)
  Missing requirement: Android Development Tools 17.0.0.v201203161636-291853 (com.android.ide.eclipse.adt.feature.group 17.0.0.v201203161636-291853) requires 'org.eclipse.core.runtime 3.6.0' but it could not be found
缘由及解决办法:
requires 'org.eclipse.core.runtime 3.6.0' but it could not be found
requires 'org.eclipse.ui 3.6.0' but it could not be found
eclipse须要升级到3.6.0,个人版本是3.5.2
【错误信息】
[2012-04-09 17:14:49 - Info] ------------------------------
[2012-04-09 17:14:49 - Info] Android Launch!
[2012-04-09 17:14:49 - Info] Connection with adb was interrupted.
[2012-04-09 17:14:49 - Info] 0 attempts have been made to reconnect.
[2012-04-09 17:14:49 - Info] You may want to manually restart adb from the Devices view.
缘由及解决办法:
从新启动eclipse
【错误信息】
[2012-04-10 09:45:49 - adb] ADB server didn't ACK
[2012-04-10 09:45:49 - adb] * failed to start daemon *
缘由及解决办法:
查看任务管理器,关闭全部adb.exe 
重启eclipse
【错误信息】
[2012-04-10 09:53:50 - ApiDemos] ------------------------------
[2012-04-10 09:53:50 - ApiDemos] Android Launch!
[2012-04-10 09:53:50 - ApiDemos] The connection to adb is down, and a severe error has occured.
[2012-04-10 09:53:50 - ApiDemos] You must restart adb and Eclipse.
[2012-04-10 09:53:50 - ApiDemos] Please ensure that adb is correctly located at 'C:\android\android-sdk-windows\platform-tools\adb.exe' and can be executed.
缘由及解决办法:
重启eclipse
【错误信息】
安装android sdk时:
-= warning! =- A folder failed to be renamed or moved. On Windows this typically means that a program Is using that Folder (for example Windows Explorer or your anti-virus software.) Please momentarily deactivate your anti-virus software. Please also close any running programs that may be accessing the directory 'C:\android\android-sdk-windows/android-sdk-windows/too!s'. When ready, press YES to try again.

缘由及解决办法:
1, 复制 tools目录
为一个新的目录 tools-copy ,此时在android-sdk-windows 目录下有两个目录 tools 和 tools-copy
2, 在tools-copy目录以管理员身份运行 android.bat ,这样就能够正常 update all 了
3.从新运行SDK Manager.exe.问题解决!
【错误信息】
“正在启动JavaEyeApiAccessor“遇到问题。
不能链接至VM

缘由及解决办法:
链接不到手机虚拟机
重启拔插手机链接线
【错误信息】
调试的时候:
[2012-04-13 17:46:27 - IpsosAutoAndroid] Failed to install IpsosAutoAndroid.apk on device '?': timeout
[2012-04-13 17:46:27 - IpsosAutoAndroid] Launch canceled!
缘由及解决办法:
链接真机调试的时候若是链接过久没响应就会出现timeout
1.在window-》prensent....-》android-》设置ddms的timeout时间。这种是就最有效、最简洁的。
2.delete android里面的 apk,保证速度。不过试过一次后,真机好像变“聪明了”,也出现timeout。
3.Cleaning the project (Project->Clean),不行就重启eclipse或者android,很郁闷的是,重启后运行第一次能够。第二次就开始变慢了,也就是出现timeout
4.关闭eclipse ,而后再重启,就ok
【错误信息】
调用org.ksoap2.*访问webservice时
04-13 10:09:49.565: E/dalvikvm(354): Could not find class 'org.ksoap2.serialization.SoapObject', referenced from method......
04-13 10:09:49.585: E/dalvikvm(354): Could not find class 'org.ksoap2.transport.HttpTransportSE', referenced from method......
【错误信息】
Unable to open stack trace file '/data/anr/traces.txt': Permission denied
缘由及解决办法:
Unable to open stack trace file '/data/anr/traces.txt': Permission 多见于这个Activity你没有在AndroidManifest.xml中注册,就会报这样的错误。
【错误信息】
source not found
找不到源
缘由及解决办法:
android目录下没有对应的sources文件

以下图,不知道为何,最新的SDK更新API 14/15中有Sources for Android SDK,而以前的版本的源码就不更新,气愤!

下载对应的SDK Sources后,放到\android-sdk-windows\sources 目录下就OK了!

【错误信息】
Android使用KSOAP2调用WebService时:
java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
缘由及解决办法:
虽然标明上 Java Build Path->Libraries中已经引用了ksoap2-android 包,可是须要order and export中也把该包勾选上

【错误信息】

error: Error: No resource found that matches the given name (at 'layout_toLeftOf' with value'@id/top_send_btn'). 
header_questionitemlist.xml /IpsosAutoAndroid/res/layout 第 27 行 Android AAPT Problem
缘由及解决办法:
【错误信息】
没法解析导入 com.renren.api.connect.android.R
缘由及解决办法:
导入android源码有错,R.java文件不能自动生成解决方法
【错误信息】
Eclipse中的DDMS没法打开data文件夹下的内容,也不能往里面写东西
缘由及解决办法:
经过软件获取ROOT权限
【错误信息】
Fri May 04 16:27:46 CST 2012
Internal error logged from JDI Debug: 
org.eclipse.jdi.TimeoutException: 等待包 8 时发生超时。
at org.eclipse.jdi.internal.connect.PacketReceiveManager.getReply(PacketReceiveManager.java:171)
at org.eclipse.jdi.internal.connect.PacketReceiveManager.getReply(PacketReceiveManager.java:180)
......
缘由及解决办法:
从新启动eclipse,不行的话重启机器
【错误信息】
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
缘由及解决办法:
以下是有问题的代码:express

Thread t = new Thread() {
@Override
public void run() {
super.run();
try {
QuestionItemlist = quesHandler.getData();
if (QuestionItemlist.size() == 0) 
{
Toast.makeText(questionitemlist2.this,"问卷题目为空",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(questionitemlist2.this,"问卷题目已经获取",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();

 

【错误信息】apache

java.lang.IllegalArgumentException: The key must be an application-specific resource id.windows

缘由及解决办法:
mRadioButton.setTag(1,sQuestionItem.get(i).getToNext());//设置监听  api

ToNext:下一题目mRadioButton.setTag(2,sQuestionItem.get(i).getToEnd());//设置监听  服务器

ToEnd:是否终止 抛出IllegalArgumentException的缘由就在于key不惟一,正确代码以下:
mRadioButton.setTag(R.id.tag_tonext,sQuestionItem.get(i).getToNext());//设置监听  网络

ToNext:下一题目mRadioButton.setTag(R.id.tag_toend,sQuestionItem.get(i).getToEnd());//设置监听  app

ToEnd:是否终止 
【错误信息】
点击Debug 运行 结果模拟器老是会弹出Waiting for Debugger 而后程序又能够正常运行
若是你想调试的时候去掉 Waiting for Debugger 提示
缘由及解决办法:重启启动机器就OK