天天看點

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

Android開發錯誤彙總

原因:

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 in[email protected])

原因有可能是以下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. 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

Android開發錯誤彙總

Exception processing async thread queue

JDI thread evaluations

處理異步現場隊列時發生了異常

JDI線程求值

Android開發錯誤彙總

原因及解決辦法:

與運作無關的錯誤,關掉'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時,會出現如下錯誤:

Android開發錯誤彙總

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  

Android開發錯誤彙總
Android開發錯誤彙總
  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 ......

Android開發錯誤彙總

原因及解決辦法:

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開發錯誤彙總

原因及解決辦法:

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

Android開發錯誤彙總

原因及解決辦法:

1, 複制 tools目錄

為一個新的目錄 tools-copy ,此時在android-sdk-windows 目錄下有兩個目錄 tools 和 tools-copy

2, 在tools-copy目錄以管理者身份運作 android.bat ,這樣就可以正常 update all 了

3.重新運作SDK Manager.exe.問題解決!

【錯誤資訊】

“正在啟動JavaEyeApiAccessor“遇到問題。

不能連接配接至VM

Android開發錯誤彙總

原因及解決辦法:

連接配接不到手機虛拟機

重新開機拔插手機連接配接線

【錯誤資訊】

調試的時候:

 [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檔案

Android開發錯誤彙總

如下圖,不知道為什麼,最新的SDK更新API 14/15中有Sources for Android SDK,而之前的版本的源碼就不更新,氣憤!

Android開發錯誤彙總

下載下傳對應的SDK Sources後,放到\android-sdk-windows\sources 目錄下就OK了!

Android開發錯誤彙總

【錯誤資訊】

Android使用KSOAP2調用WebService時:

 java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject

原因及解決辦法:

雖然标明上 Java Build Path->Libraries中已經引用了ksoap2-android 包,但是需要order and export中也把該包勾選上

Android開發錯誤彙總

【錯誤資訊】

Android開發錯誤彙總

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  

Android開發錯誤彙總
Android開發錯誤彙總
  1. <span style="font-size:14px">     Thread t = new Thread() {  
  2.             @Override  
  3.             public void run() {  
  4.                 super.run();  
  5.                 try {  
  6.                     QuestionItemlist = quesHandler.getData();  
  7.                     if (QuestionItemlist.size() == 0) {  
  8.                         Toast.makeText(questionitemlist2.this,"問卷題目為空",Toast.LENGTH_LONG).show();  
  9.                     } else {  
  10.                         Toast.makeText(questionitemlist2.this,"問卷題目已經擷取",Toast.LENGTH_LONG).show();  
  11.                     }  
  12.                 } catch (Exception e) {  
  13.                     e.printStackTrace();  
  14.                 }  
  15.             }  
  16.         };  
  17.         t.start();</span>  

【錯誤資訊】

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

原因及解決辦法:

[java]  view plain  copy  

Android開發錯誤彙總
Android開發錯誤彙總
  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  

Android開發錯誤彙總
Android開發錯誤彙總
  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'

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

Android開發錯誤彙總

原因及解決辦法:

可能是程式中缺少資源檔案之類的

下圖點選window->preferences如下圖

Android開發錯誤彙總

點選android下面的lint error checking ->勾選掉run full error ....如下圖

Android開發錯誤彙總

【錯誤資訊】

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

  • 移動調研解決方案: 51wajue.com

【錯誤資訊】

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了。這兩個包與自帶的包沖突了

Android開發錯誤彙總

【錯誤資訊】

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  

Android開發錯誤彙總
Android開發錯誤彙總
  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. />  
Android開發錯誤彙總

"txtJiangli_Out_all"向右看齊,“txtJiangliOut”靠齊 " txtJiangli_Out_all "控件,但如上會出錯,問題在哪?

解決辦法:

由于"txtJiangli_Out_all"控件擺放在“txtJiangliOut”前面,是以就找不到後面的控件,是以把順序換下就好了,如下:

[java]  view plain  copy  

Android開發錯誤彙總
Android開發錯誤彙總
  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. <TextView android:id="@+id/txtJiangliOut"  
  10.      android:layout_width="wrap_content"  
  11.      android:layout_height="wrap_content"   
  12.      android:text="@string/jiangliOut"   
  13.      android:layout_toLeftOf="@id/txtJiangli_Out_all"  
  14.      style="@style/normalText"  
  15. />  

【錯誤資訊】

作業系統換成了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-》更新并安裝

【錯誤資訊】

android橫豎屏切換時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開發錯誤彙總
Android開發錯誤彙總

解決辦法:

android:[email protected];//将預設的button圖檔清空

android:[email protected]/radiobutton;//使用該屬性定義button圖檔

android:[email protected];//将radioButton的背景設為空

android:drawablePadding=6dp;//将文字和左側的button圖檔相距6dp

button/drawableLeft/background/drawablePadding結合使用方可改變文字和圖檔的距離 ;

如果button是動态生成的則用如下:

[html]  view plain  copy  

Android開發錯誤彙總
Android開發錯誤彙總
  1. RadioButton rdbtn = (RadioButton) LayoutInflater.from(empView_).inflate(R.layout.tabmenu_radiobutton, null);  

[html]  view plain  copy  

Android開發錯誤彙總
Android開發錯誤彙總
  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  

Android開發錯誤彙總
Android開發錯誤彙總
  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

繼續閱讀