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源程序后点“运行”按钮)

Android开发遇到的异常及解决办法,布布扣,bubuko.com

Android开发遇到的异常及解决办法

上一篇:xmpp ios 问题篇


下一篇:WebService一些概念