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]  view plain  copy
  1. 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()

 

修改后:

[java]  view plain  copy
  1. <span style="font-size:14px;" class="Apple-style-span">new AlertDialog.Builder(com.nantsing.infoquery.chuanbo_detail.this).setTitle("数据加载失败").setMessage("请检查网络连接情况")           .setPositiveButton("OK"new DialogInterface.OnClickListener(){            public void onClick(DialogInterface dialoginterface, int i)            {            }</span>  

 

误信息】

The constructor AlertDialog.Builder(chuanbo_detail.HttpThread) is undefined

原因及解决办法:

在UI主线程之外是无法对UI组件进行控制的。因为你必须在新线程任务完成之后利用各种方法先UI主线程发送消息通知任务完成从而来显示各种提示消息。
线程间通信方法有多种,常用的是用handler来传递消息。

如下:

线程中构造消息:

 

[java]  view plain  copy
  1. //构造消息Message message = handle.obtainMessage();Bundle b = new Bundle();b.putString("tag", "1");message.setData(b);handle.sendMessage(message);  

另外自定义消息:

[c-sharp]  view plain  copy
  1. /** * 捕获消息队列 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

处理异步现场队列时发生了异常

JDI线程求值

 

原因及解决办法:

与运行无关的错误,关掉'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文件。添加一行:

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <span style="font-size:14px">74.125.237.1       dl-ssl.google.com</span>  

保存,重新启动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

This Android SDK requires Android Developer Toolkit version 17.0.0 or above.

Current version is 15.0.0.V201110251216-213216.

Please update ADT to latest version.

 

原因及解决办法:

最新的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

原因及解决办法:

requires 'org.eclipse.core.runtime 3.6.0' but it could not be found

eclipse需要升级到3.6.0,我的版本是3.5.2

误信息】

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()

原因及解决办法:

 

如下是有问题的代码: 

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <span style="font-size:14px">     Thread t = new Thread() {  
  2.             @Override  
  3.             public void run() {  
  4.                 super.run();  
  5.                 try {  
  6.   
  7.                     QuestionItemlist = quesHandler.getData();  
  8.                     if (QuestionItemlist.size() == 0) {  
  9.                         Toast.makeText(questionitemlist2.this,"问卷题目为空",Toast.LENGTH_LONG).show();  
  10.                     } else {  
  11.                         Toast.makeText(questionitemlist2.this,"问卷题目已经获取",Toast.LENGTH_LONG).show();  
  12.                     }  
  13.                 } catch (Exception e) {  
  14.                     e.printStackTrace();  
  15.                 }  
  16.             }  
  17.         };  
  18.         t.start();</span>  

误信息】

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

原因及解决办法:

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <span style="font-size:14px">mRadioButton.setTag(1,sQuestionItem.get(i).getToNext());//设置监听  ToNext:下一题目  
  2. mRadioButton.setTag(2,sQuestionItem.get(i).getToEnd());//设置监听  ToEnd:是否终止</span>  

抛出IllegalArgumentException的原因就在于key不唯一,正确代码如下:

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <span style="font-size:14px">mRadioButton.setTag(R.id.tag_tonext,sQuestionItem.get(i).getToNext());//设置监听  ToNext:下一题目  
  2. mRadioButton.setTag(R.id.tag_toend,sQuestionItem.get(i).getToEnd());//设置监听  ToEnd:是否终止</span>  


误信息】

点击Debug 运行 结果模拟器总是会弹出Waiting for Debugger 然后程序又可以正常运行

如果你想调试的时候去掉 Waiting for Debugger 提示

原因及解决办法:

重启启动平板电脑机器就OK

 

误信息】

拔掉连接线,运行程序还出现如下问题:

android Debuger 出现:"Waiting for Debugger - Application XXX is waiting for the debugger to Attach"

然后关闭

原因及解决办法:

重启机器或者重启下adb
 

误信息】

AndroidManifest.xml配置中加入android:installLocation="auto"出现错误:
error: No resource identifier found for attribute 'installLocation' in package 'android'

原因及解决办法:

开发包需要Android2.2以上

Change the build target by editing the project properties (right-click on the project in Eclipse), and choose a target with at least API Level 8

 

误信息】

[2012-08-22 17:21:53 - IpsosAutoAndroid] Project has no project.properties file! Edit the project properties to set one.
[2012-08-22 17:22:16 - IpsosAutoAndroid] Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

原因及解决办法:

Project / Properties / Java Compiler  ,查看Compiler compliance level 指定的版本号被指定为1.6,并且Enable project specific seetings 被勾选。

 

误信息】

Android Tools->Export Signed Application Package

出错

Export aborted becase fatal lint errors were found.
These are listed in the Problems view. Either fix these before running 
Export again, or turn off "Run full error check when exporting app" in 
the Android > Link Error Checking preference page

原因及解决办法:

可能是程序中缺少资源文件之类的

下图点击window->preferences如下图

点击android下面的lint error checking ->勾选掉run full error ....如下图

误信息】

Android 签名打包时出现下面错误:

[2012-09-09 00:15:34 - IpsosAutoAndroid] Proguard returned with error code 1. See console
[2012-09-09 00:15:34 - IpsosAutoAndroid] Note: there were 4 duplicate class definitions.
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlSerializer
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
[2012-09-09 00:15:34 - IpsosAutoAndroid]       You should check if you need to specify additional program jars.
[2012-09-09 00:15:34 - IpsosAutoAndroid] Warning: there were 7 instances of library classes depending on program classes.
[2012-09-09 00:15:34 - IpsosAutoAndroid]          You must avoid such dependencies, since the program classes will
[2012-09-09 00:15:34 - IpsosAutoAndroid]          be processed, while the library classes will remain unchanged.
[2012-09-09 00:15:34 - IpsosAutoAndroid] java.io.IOException: Please correct the above warnings first.
[2012-09-09 00:15:34 - IpsosAutoAndroid]  at proguard.Initializer.execute(Initializer.java:321)
[2012-09-09 00:15:34 - IpsosAutoAndroid]  at proguard.ProGuard.initialize(ProGuard.java:211)
[2012-09-09 00:15:34 - IpsosAutoAndroid]  at proguard.ProGuard.execute(ProGuard.java:86)
[2012-09-09 00:15:34 - IpsosAutoAndroid]  at proguard.ProGuard.main(ProGuard.java:492)

原因及解决办法:

可能是因为引用了第三方开发包:ksoap2-android-assembly-2.4-jar-with-dependencies.jar

不需要混淆的把混淆的proguard.cfg去掉就好了

Or

在proguard.cfg中增加一行
-ignorewarnings

http://www.eoeandroid.com/thread-114519-1-1.html

 

误信息】

打开eclipse出现如下错误:

描述 资源 路径 位置 类型
Error generating final archive: Debug Certificate expired on 12-10-18 下午12:10 IpsosAutoAndroid  未知 

Android Packaging Problem

原因及解决办法:

进入C:\Documents and Settings\Administrator\.android 删除路径下的debug.keystore及 ddms.cfg。

 

误信息】

通过包:ksoap2-android-assembly-2.4-jar-with-dependencies.jar调用webservice时,在如下代码中出错:

SoapObject request = new SoapObject(Constant.NAMESPACE,   methodName);


原因及解决办法:

java构建路径时,引用包时目录路径不能有中文字体。


误信息】

想通过Service启动安装文件时

UpdateService.this.startActivity(i);

出现如下错误:

android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

原因及解决办法:

Intent后需要添加setFlags:

Intent i = new Intent(Intent.ACTION_VIEW);

it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);


误信息】

java.lang.NoSuchMethodError:android.util.Xml.newSerializer

调试状态,调用XML序列化拼接代码没有问题

XmlSerializer serializer = Xml.newSerializer();

但是签名发布之后,却报运行时错误

原因及解决办法:

初步判断是Android用ProGuard混淆后,xmlpull与另外一个引用包中的ksoap2-android-assembly-2.4-jar-with-dependencies.jar冲突

解决办法是首先用快压打开ksoap2-android-assembly-2.4-jar-with-dependencies.jar包,然后把对应的org.xmlpull.v1.XmlPullParser和org.xmlpull.v1.XmlSerializer去掉,就OK了。这两个包与自带的包冲突了



误信息】

Eclipse安装了中文包后就没有办法调试进入查看源代码,并出现下面的错误:

未能打开编辑器:Unmatched braces in the pattern.

解决办法:

配置自己Eclipse的启动参数  eclipse.ini  在最后面加入这段代码   -Duser.language=en

然后打开Eclipse  这是Eclipse应该变为英文的了

点击attach source

选择 src.zip包 在java jdk下面

英文界面显示成功

下面切换回来中文  把刚才在eclipse.ini里添加的 最后那一段删除  重启Eclipse

点击源代码查看  大功告成


误信息】

调试的时候,一直停留 waiting for debugger Application ......is waiting for the debugger to attach

解决办法:

同时打开多个eclipse进行调试,需要关闭掉一个

这时模拟器可能不能正确辨别是哪个eclipse正在进行debug
从而会一直停留在“等待调试器连接”的提示上

【错误信息】

[2013-09-06 18:05:50 - Q***Android] Failed to install Q***Android.apk on device '?': Too many open files
[2013-09-06 18:05:50 - Q***Android] com.android.ddmlib.SyncException: Too many open files
[2013-09-06 18:05:50 - Q***Android] Launch canceled!

解决办法:

解决方法1:拔掉手机连接线再重新连上;

解决方法2:在手机上关闭Debug选项再重新打开,这个选项在手机的"设置->应用程序->开发->USB调试"里。


误信息】

线程Thread()中刷新界面控件赋值时出现如下错误:

Only the original thread that created a view hierarchy can touch its views.

解决办法:

需要使用Android异步处理,使用Thread+Handler实现非UI线程更新UI界面

【错误信息】

ScrollView can host only one direct child

解决办法:

ScrollView内部只能有一个子元素,即不能并列两个子元素,所以需要把所有的子元素放到一个LinearLayout内部或RelativeLayout等其他布局方式让后再在这个layout外部用scrollview包住。

【错误信息】

error: Error: No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/txtJiangli_Out_all').

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <TextView android:id="@+id/txtJiangliOut"  
  2.      android:layout_width="wrap_content"  
  3.      android:layout_height="wrap_content"   
  4.      android:text="@string/jiangliOut"   
  5.      android:layout_toLeftOf="@id/txtJiangli_Out_all"  
  6.      style="@style/normalText"  
  7. />                 
  8. <TextView   
  9.      android:id="@+id/txtJiangli_Out_all"  
  10.      android:layout_width="wrap_content"  
  11.      android:layout_height="wrap_content"   
  12.      android:layout_alignParentRight="true"  
  13.      android:text="0.0元"   
  14.      style="@style/normalText"  
  15. />  

"txtJiangli_Out_all"向右看齐,“txtJiangliOut”靠齐 " txtJiangli_Out_all "控件,但如上会出错,问题在哪?

解决办法:

"

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <TextView   
  2.      android:id="@+id/txtJiangli_Out_all"  
  3.      android:layout_width="wrap_content"  
  4.      android:layout_height="wrap_content"   
  5.      android:layout_alignParentRight="true"  
  6.      android:text="0.0元"   
  7.      style="@style/normalText"  
  8.        
  9. />  
  10. <TextView android:id="@+id/txtJiangliOut"  
  11.      android:layout_width="wrap_content"  
  12.      android:layout_height="wrap_content"   
  13.      android:text="@string/jiangliOut"   
  14.      android:layout_toLeftOf="@id/txtJiangli_Out_all"  
  15.      style="@style/normalText"  
  16. />  


【错误信息】

操作系统换成了WIN8,在创建模拟器后,启动模拟器提示:

PANIC: Could not open AVD config file:c:\user\乱码\....

解决方法:

在我的电脑右键属性配置系统环境变量

名称:ANDROID_SDK_HOME

路径:C:\android\android-sdk-windows   这个路径你可以随便但不要有中文

然后找到eclipse安装路径找到

比如我的:E:\JAVA\eclipse-java-indigo-SR1-win32\eclipse\configuration\.settings

找到org.eclipse.ui.ide.prefs 文件 用记事本打开

在最后面加上环境变量中添加的路径   

ANDROID_SDK_Home=C\:\\android\\android-sdk-windows  注意这里的反斜杠

重启eclipse 重新创建模拟器


【错误信息】

[2015-05-26 11:54:05 - eoecn] Unable to resolve target 'android-17'

解决办法:

没有安装最新的SDK

窗口-》Android SDK Manager-》更新并安装

【错误信息】

Activity会重新执行onCreat函数,这样造成程序无法正常运行

解决办法:

在Android工程的AndroidManifest.xml中

加入android:screenOrientation="user" android:configChanges="orientation|keyboardHidden"之后

  1. <activity android:name=".MainActivity" android:label="@string/app_name"  
  2.     android:screenOrientation="user" android:configChanges="orientation|keyboardHidden">
  3. </activity> 

只想让它一直是横屏表示的话,只要AndroidManifest.xml设置android:screenOrientation="landscape"就行了。

【错误信息】

RadioButton及CheckBox排版时,按钮与文字之间距离根据不同的Android版本显示不同,Android4.0之前的都是正常的,Android4.0之后的如下图,显示有重叠。(radiobutton 文字和图片重叠)



解决办法:

android:button=@null;//将默认的button图片清空

android:drawableLeft=@drawable/radiobutton;//使用该属性定义button图片

android:background=@null;//将radioButton的背景设为空

android:drawablePadding=6dp;//将文字和左侧的button图片相距6dp

button/drawableLeft/background/drawablePadding结合使用方可改变文字和图片的距离 ;


如果button是动态生成的则用如下:

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. RadioButton rdbtn = (RadioButton) LayoutInflater.from(empView_).inflate(R.layout.tabmenu_radiobutton, null);  

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RadioButton   
  3.     xmlns:android="http://schemas.android.com/apk/res/android"  
  4.     style="@style/radioButton"  
  5.     android:layout_width="fill_parent"  
  6.     android:layout_height="wrap_content"  
  7.     >  
  8. </RadioButton>   

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <resources>    
  2.     <style name="radioButton">  
  3.         <item name="android:textColor">#444</item>  
  4.         <item name="android:button">@null</item>  
  5.         <item name="android:drawableLeft">@drawable/radiobtnbg</item>  
  6.         <item name="android:background">@null</item>  
  7.         <item name="android:drawablePadding">5dp</item>  
  8.     </style>   
  9. </resources>    

【错误信息】

exclipe发布Android项目新版本时,新版本无法安装,明明是准备安装的是新版本,但错误提示:

暂停安装:手机上已安装高版本应用,请卸载后

解决办法:

试过了很多次,怀疑是跨年度的原因,跨年度了新版本被识别是旧版本。

最后检查发布新版本的时候只更新了android:versionName="***"但未更新android:versionCode="***"

【错误信息】

创建模拟器4.4.2时后,出现如下提示:

Unable to find a 'userdata.img' file for ABIarmeabi to copy into the AVD folder.

解决方法:

没有下载安装"ARM EABI v7a System Image"

【错误信息】

Android 4.4.2之后无法启动模拟器。

网上收集到的解决方法有如下几种,我都没有用上,不过碰到问题时都可以一试:
1、在创建avd的时候,它的name就像是java中创建class一样,首字母一定要大写,要不然系统就不能识别出来,就会出现无法写入的情况。、
2、创建sdcard的时候,size 可以不进行设置,如果你没创建sdcard的话,那里设置也没用,主要是file那里要指向你所创建的sdcard的路径,也就是sdcard.mimg,这时候sdcard已经存在了,就不要在size里面输入sdcard大小,要不然就会出现错误。
3、升级显卡驱动程序到最新版本。
4、启用显卡的GPU emulation,在建立AVD的时候,下方有一个Hardware选项,点击右边的New按钮,选择GPU emulation,确定,将Hardware表格中的GPU emulation改为yes即可;如果升级新版SDK之后就没有hardware选项了,这时只需将use host gpu打钩。
5、把RAM的大小都改小到768m以下。
6、分辨率的问题,创建AVD的分辨率太高,电脑不支持,修改模拟器的屏幕分辨率,或者修改电脑的分辨率试试
7、是不是Android 4.4之后强制只能用java7,目前用的是java6

后面没有办法安装android模拟器genymotion,但是创建虚拟设备时出现如下错误:

unable to create virtual device server returned http status code 0 

找了半天找不到什么原因。

【错误信息】

APP中listview绑定ListAdapter接口

 listview.setAdapter(separatedAdapter);

但出现奇怪的问题,绑定数据量一多,就出现无法绑定的不能扑捉的错误

java.lang.ClassCastException: ***.QuestionsAdapter cannot be cast to android.widget.BaseAdapter


作者:水煮鱼
出处:http://blog.csdn.net/panfb227

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值