Android開發遇到的異常及解決辦法,android解決辦法
Android開發遇到的錯誤及解決方案
1. Unable to resolve target 'android-7'
解決方案:
修改工程目錄下的default.properties檔案裡的內容target=android-7改成target=android-12(或者其他版本)就可以了,最好用txt開啟,然後修改之後儲存,運行就可以了。
原代碼如下:
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-8
--------------------------------------------
2. Android Error: Unable to open class file R.java
You’ve just installed Eclipse , and attempted to create your first Android Application. When clicking create, you see an error similar to this: "Error: Unable to open class file R.java "
如果出現 “Error: Unable to open class file R.java No such file or directory”。
Solution:解決方案:
The “Build Path” for your Java environment is not setup correctly in Eclipse. To fix this, follow these steps:
1) Open the Preferences Window by clicking “Window -> Preferences”
2) Find the “Java” section and expand it
3) Select “Build Path ”
4) Change the value of Source and output folder from Folders to “Project ”
5) Click Apply and then “OK ”
Your problem should be resolved!
-------------------------------------
3. 學習android的開發,才剛開始,不知道什麼原因,建立一個helloworld,eclipse就蹦出個錯誤,晴高手指點一
ERROR: Unable to open class file E:\Users\Administrator\workspace\helloworld1\gen\fanghui\helloworld\R.java: No such file or directory
要看你用的哪個sdk版本開發的, 不同版本工程檔案結構稍有不同 ,最新的2.2中 解決辦法是 你把gen檔案夾刪除 然後點擊功能表列中的project—》clean,快顯視窗中選擇你的工程 確定應該就沒有問題了
---------------------------------------
4. 求助:我是新手,最近在照書學習時,匯入的程式都在項目的表徵圖處有個紅叉,
提示:ERROR:Unable to open class file ..\..\R.java Permission denied
請問這種情況是什麼導致的 ?
Help with “Error: Unable to open class file R.java” when building an Android App for the first time in Eclipse
This is just a really, quick and dirty post to help resolve this issue.
Problem:
You’ve just installed Eclipse (5.2.x at the time of this writing), and attempted to create your first Android Application. When clicking create, you see an error similar to this:
Error: Unable to open class file R.java
Solution:
The “Build Path” for your Java environment is not setup correctly in Eclipse. To fix this, follow these steps:
1) Open the Preferences Window by clicking Window -> Preferences
2) Find the Java section and expand it
3) Select Build Path
4) Change the value of Source and output folder from Folders to Project
5) Click Apply and then OK
Your problem should be resolved!
----------------------------------
5. 求助:我是新手,最近在照書學習時,匯入的程式都在項目的表徵圖處有個紅叉,
提示:ERROR:Unable to open class file ..\..\R.java Permission denied
請問這種情況是什麼導致的 ?
第二種解決方式:1.先檢查你的代碼,代碼有誤,R.java檔案是產生不了的(一般匯入的程式是不會有這個問題的) 2. 開啟Project ----> Build Automatically那個選項勾上,讓工程每次修改完後都會自動編譯,這樣R.java會是最新的(這時候程式有誤,不會產生) 3. Project ---> Clean,點開後,選中你的工程,然後OK,(clean本身就會Reset你的工程設定,並且在之後能自動重新Build一下,如果一次clean還是有問題,那就再clean。一般兩次就可以了)。這樣三步下來,就能搞定你的問題了
我clean 了還是不行啊
-------------------------------------
6. 今天我匯入一個遊戲demo的工程,發現項目名稱上有紅叉,控制台拋出錯誤報表
[2011-01-13 13:47:42 - DrifBall] ERROR: Unable to open class file G:\Android2.0遊戲開發實踐寶典原始碼\原始碼\第14章\DrifBall\gen\wyf\wpf\R.java: Permission denied
上網搜了一下“Permission denied”,說要更改項目的唯讀屬性,結果我沒找到,這個問題到底是怎麼回事啊?
你右鍵點擊唯讀檔案->屬性->去掉唯讀選項的鉤就不會再提示了
右鍵點擊項目format,然後會有提示你的檔案為唯讀,是否改為可修改,選擇確定就好了#10樓
參照10樓的 成功解決了問題
-------------------------------------
7. Android程式調試時產生main.out.xml檔案,報錯: Resource entry main is already defined
學習Android,調試中報錯,
20:47:58 - TextView] Error in an XML file: aborting build.
[2011-09-07 20:47:58 - TextView] res\layout\main.xml:0: error: Resource entry main is already defined.
[2011-09-07 20:47:58 - TextView] res\layout\main.out.xml:0: Originally defined here.
代碼沒有問題。
原來是Eclipse問題,運行當前頁放在main.xml檔案下,切換到.java檔案。刪除main.out.xml,運行ok
這樣下次還是比較麻煩,每次需要切換。
可以在Eclipse裡面配置,菜單Windows->Preference,選擇結點Run/Debug->Lauching,Lauch Operation選擇第一項。
-----------------------------------
8. Android開發中總是產生*.out.xml問題
我改寫了layout下自己main.xml後,編譯總是又產生一個main.out.xml並且提示如下錯誤
Error in an XML file: aborting build.
[2010-04-01 00:38:45 - AndroidPhoneDialer] res\layout\main.xml:0: error: Resource entry main is already defined.
[2010-04-01 00:38:45 - AndroidPhoneDialer] res\layout\main.out.xml:0: Originally defined here.
[2010-04-01 00:38:45 - AndroidPhoneDialer] F:\workspace\AndroidPhoneDialer\res\layout\main.out.xml:1: error: Error parsing XML: no element found
[2010-04-01 00:55:29 - AndroidPhoneDialer] Error in an XML file: aborting build.
[2010-04-01 01:07:46 - AndroidPhoneDialer] Error in an XML file: aborting build.
[2010-04-01 10:52:35 - AndroidPhoneDialer] Error in an XML file: aborting build.
網上有人說要設定SCR的焦點,不知道怎麼弄,求教~
我用的是eclipse IDE,百度Hi線上可以直接交流~~多謝了
這個我也遇到了。其實很簡單,你在開啟一個 XML 檔案的時候直接點了“運行”按鈕就會這樣了。
解決的方法:把產生的*.out.xml檔案刪除了之後,點“運行”按鈕的向下箭頭,選擇你要啟動並執行程式就可以了。(也可以開啟你的*.java來源程式後點“運行”按鈕)