1. 程式人生 > >Android常見錯誤集錦

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

Url指的是你的webservice的地址.一般都是以***.wsdl或者***.?wsdl結束的...但是.需要注意的是..要去掉後面的.wsdl或者.?wsdl

【錯誤資訊】

 在新的執行緒中 public class HttpThread extends Thread {...}

增加一個彈出窗體:

  1. new AlertDialog.Builder(this).setTitle("資料載入失敗").setMessage("請檢查網路連線情況")           .setPositiveButton("OK"new DialogInterface.OnClickListener(){            public void onClick(DialogInterface dialoginterface, int i)            {            }            }).show();  
  1. new AlertDialog.Builder(this).setTitle("資料載入失敗").setMessage("請檢查網路連線情況")           .setPositiveButton("OK"new DialogInterface.OnClickListener(){            publicvoid onClick(DialogInterface dialoginterface, int i)            {            }            }).show();  

  原因及解決辦法:

//不能線上程中操作UI介面

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

修改後:

  1. new AlertDialog.Builder(com.nantsing.infoquery.chuanbo_detail.this).setTitle("資料載入失敗").setMessage("請檢查網路連線情況")           .setPositiveButton("OK"new DialogInterface.OnClickListener(){            public void onClick(DialogInterface dialoginterface, int i)            {            }  
  1. new AlertDialog.Builder(com.nantsing.infoquery.chuanbo_detail.this).setTitle("資料載入失敗").setMessage("請檢查網路連線情況")           .setPositiveButton("OK"new DialogInterface.OnClickListener(){            publicvoid onClick(DialogInterface dialoginterface, int i)            {            }  

【錯誤資訊】

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

原因及解決辦法:

在UI主執行緒之外是無法對UI元件進行控制的。因為你必須在新執行緒任務完成之後利用各種方法先UI主執行緒傳送訊息通知任務完成從而來顯示各種提示訊息。
執行緒間通訊方法有多種,常用的是用handler來傳遞訊息。

如下:

執行緒中構造訊息:

  1. //構造訊息Message message = handle.obtainMessage();Bundle b = new Bundle();b.putString("tag", "1");message.setData(b);handle.sendMessage(message);  
  1. //構造訊息Message message = handle.obtainMessage();Bundle b = new Bundle();b.putString("tag", "1");message.setData(b);handle.sendMessage(message);

另外自定義訊息:

  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();}}};  
  1. /** * 捕獲訊息佇列 fubin.pan 2011-04-02 */Handler handler = new Handler() {publicvoid handleMessage(Message m) {if (!m.getData().getString("tag").equals("1")){                            ...}else{new AlertDialog.Builder(chuanbo_detail.this).setTitle("資料載入失敗").setMessage("請檢查網路連線情況!")         .setPositiveButton("OK"new DialogInterface.OnClickListener(){             publicvoid 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時出錯

這是 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時,會出現如下錯誤:

reason: Connection timed out: connect

原因及解決辦法:

dl-ssl.google.com在大陸封掉了

解決方法就是修改C:\Windows\System32\drivers\etc\hosts檔案。新增一行:

  1. 74.125.237.1       dl-ssl.google.com  
  1. 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

這裡可不能用常規方法安裝這個 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()

原因及解決辦法:

如下是有問題的程式碼: 

  1. 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();  
  1. Thread t = new Thread() {  
  2.     @Override
  3.     publicvoid run() {  
  4.         super.run();  
  5.         try {  
  6.             QuestionItemlist = quesHandler.getData();  
  7. 相關推薦

    android 常見錯誤集錦

    執行 使用 andro tar fragment art new 集錦 fin 1、在非UI線程中創建fragment對象,然後start(fragment),在fragment的操作中用到了handler,這一會報錯,handler can‘t create before

    Android常見錯誤集錦

    【錯誤資訊】 [2011-01-19 16:39:10 - ApiDemos] WARNING: Application does not specify an API level requirement! [2011-01-19 16:39:10 - ApiDem

    Android 開發常見錯誤集錦

    Android 開發問題集錦 1.   java.lang.UnsatisfiedLinkError:Couldn't load locSDK4b: findLibrary returned  null          在libs下新建一個armeabi-v7a,然後將

    Android常見錯誤android widget LinearLayout 4375f248 that was or

    分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

    android開發錯誤集錦

      Error:Execution failed for task ':app:validateSigningBaiduDebug'.   > Keystore file          D:\project_spac

    android 常見錯誤:fabric connection timeout

     Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to maven.fabric.io:443  [maven.fabr

    Android 常見錯誤以及解決方法

    01、 解決方案: Gradle的一個Bug,解決辦法是,刪除專案根目錄的.gradle資料夾,然後Clean ,Rebulid。  02、git 提交程式碼無法提交問題 Unable to create 'D:/work/******/.git/index.lo

    Android常見錯誤彙集

    1.  Caused by: java.lang.ClassNotFoundException: Didn't find class "android.os.PersistableBundle" on path: DexPathList[[zip file "/data/a

    新手android 開發 錯誤集錦(持續更新中)

    (1)error opening trace file: No such file or directory (2) 這是寫的第一個程式就出現的問題,而且查詢程式碼沒有發現錯誤。google後得出結論:模擬器版本和android的API版本不對應,相應的進行修改就行。 (2)出現java.lang.Num

    PCB常見錯誤集錦

    一、#1 Error  Output Pins And Power Pins On Net +10V   Output Pins              : mc1490.SCH(U2-1 @410,570)   Power Pins               : mc1490.SCH(U2-2 @410

    32位Ubuntu編譯android常見錯誤

    原文: 連結 開始正式編譯,在原始碼目錄下make即可。 make 我完全不知道跑了個啥,只知道超級卡。完成後產生的out資料夾有3.9G。 映象生成在out/target/product/generic下:android原始碼編譯後得到system.img,ram

    六、 Android常見錯誤 (持續更新中……)

    1、Unable to resolve target 'android-2' 安裝低版本的api,再default.properties這個檔案中把target=android-2改成 target=android-7終於就沒有問題了。 2、Invalid start tag LinearLayout

    Android開發——錯誤集錦

    1、could not find any version that matches com.android.support:appcompact-v7:25.+ 原因:由於Android Stud

    android 常見錯誤

    1.控制檯輸出:called unimplemented OpenGL ES API 呼叫了未實現的OpenGL ES API函式,一般由於匯入的第三方庫如地相簿,裡面有用到OpenGL,但是模擬器的硬體預設是沒有這個的,所以需要我們編輯模擬器Emulation Options選項勾選 Us

    Verilog常見錯誤集錦

    說明:本文內容來自網路 1.Error (10028): Can't resolve multiple constant drivers for net …… 解析:不能在兩個以上always內對同一變數賦值,這個細節一般看書看資料會看到,但是程式設計時,就是沒想到。

    JAVA程式設計常見錯誤集錦(2)

    32, car is not mapped  可能1: 在cfg.xml中沒有增加對映的hbm.xml檔案在<mapping.../>中 33, 屬性沒有找到  可能1: hbm.xml檔案中的 <property name =""> 有問題, 也許是name的值與對應類中的成員名

    Java-常見錯誤集錦

    1.遍歷時,從列表裡刪除元素 1.1.測試程式碼: /** * 遍歷時,從列表裡刪除元素 */ private static void testLi

    AS Android開發 錯誤集錦

    一、專案依賴庫和主程式的allowBackup衝突: Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : Attribute applicatio

    Android問題集錦轉載之三:Javah 常見錯誤記錄-NDK與JNI除錯

    測試檔案:hello-jni/src/com/example/hellojni/HelloJni.java/** * 該檔案來自 Android NDK Sample - HelloJni, 為了便於說明問題,我作了一些修改。 */ package com.example

    Android 開發常見錯誤及解決方法集錦

                                                     作者:段興               2014-5-24 1    DescriptionThe container 'Android Dependencies' refe