ANDROID (eclipse)开发常见问题及解决办法汇总

ANDROID (eclipse)开发常见问题及解决办法汇总

1、ANDROID 在eclipse中没有出现AVD的解决方法(转)
如果android安装正确的话,但是eclipse里面的导航条就是没有AVD
可以通过「Window」⇒「Customize Perspective」⇒「Tool Bar Visibility」Tab画面上选择 Android SDK and AVD Manager来显示
http://blog.sina.com.cn/s/blog_79aa896901015iyc.html


2、Unable to get view server version from device emulator-5554 解决办法

情况描述:
exlipse下编写好android应用程序时候,右键项目 run as android application 弹出一对话框说出现问题 点击详细说 空指针异常。打开ddms模式,里面提示 Unable to get view server version from device emulator-5554 ,此时我的android模拟器是运行着的。
解决办法:删除工作空间中的.metadata 文件夹
一下为详细步骤:
(1)打开eclipse工作空间(在位置在你的eclipse中菜单windows ——> Preferences ——> General Startup and Shutdown ——>Workspaces 里面显示)
(2)关闭eclipse , 删除上面打开的工作空间中.metadata 文件夹
(3)点击 gotoWorkspaces (就是那个最后面的向右的箭头)发现eclipse中没有任何项目
(4)(导入项目)点击File菜单----Import按钮------打开对话框中选择General中Existing Prjoect into workspace 再点击 Next 第一行中右面按钮选择Browse选择workspase所在的位置(刚刚删除了文件夹的那个文件夹)点击finish 完成项目的导入(不要选择copy project into workspace)

http://blog.csdn.net/aeolus1019/article/details/8075096

3、Invalid project description. xxxx(project path) overlaps the location of another project: 'xxxx'

new -> android project -> create project from exist source
出现如下错误信息:
Invalid project description
------>detail: ->>> xxxx(project path) overlaps the location of another project: 'xxxx'

(1)分析1
原因:
下载工程时把该工程放在了workspace目录下。eclipse插件在创建项目的时候需要在workspace目录下创建一个同名的目录。 但发现workspace目录下已存在对应的目录时,就会报上面的处错误信息了。

解决方法:
把工程从workspace中移出来就可以了,重新导入就可以了。
http://blog.csdn.net/imyang2007/article/details/7888263
(2)eclipse-File-import-选"General"---"Existing Projects into Workspace"即可

注:不要选“Android”下的“Existing Projects into Workspace”

ANDROID (eclipse)开发常见问题及解决办法汇总

4、android avd 的时间总是不跟电脑一样的
AVD是一个手机设备(虚拟的),可以在Settings--Date&Time里设置时区、时间格式、是否和网络同步即可

5、 [aapt] invalid resource directory name: res/crunch
运行ant debug后 :

[aapt] invalid resource directory name: {workspace}{project name}in es/crunch

BUILD FAILED

原因分析:

这种情况是版本不一致造成的,这个无效的目录不是当前编译的时候生成的,有可能是Debug情况下,生成的。因为1.6版本以前是只有drawable一个图片资源目录。所以,

解决方法一:

修改项目版本到1.6以上。

解决方法二:

直接在项目的bin目录删除crunch文件夹。
因为bin下的内容是从项目中copy过来的,删除不会有什么影响,重新compile下就有了。
http://blog.csdn.net/studynote/article/details/22147461

6、Unexpected text found in layout file: """
在一个简单的 Android 布局文件中,Eclipse 老是警告: Unexpected text found in layout file: """
该异常解决办法:
CTRL + SHIFT + F 格局化文件后,就可以看到多余的“,删除就是了。
7、Accessibility] Missing contentDescription attribute on image

在一些没有文本显示的控件里,如imageView和imageButton等,ADT会提示你定义一个android:contentDescription属性,用来描述这个控件的作用。英文原文如下: 

Resolved this warning by setting attribute android:contentDescription for my ImageView

android:contentDescription="@string/desc"

Android Lint support in ADT 16 throws this warning to ensure that image widgets provide a contentDescription

This defines text that briefly describes content of the view. This property is used primarily for accessibility. Since some views do not have textual representation this attribute can be used for providing such.

Non-textual widgets like ImageViews and ImageButtons should use the contentDescription attribute to specify a textual description of the widget such that screen readers and other accessibility tools can adequately describe the user interface.

 原文链接:http://*.com/questions/8500544/android-lint-contentdescription-warning

 http://blog.csdn.net/hn307165411/article/details/7179317

8、ActivityManager: Warning: Activity not started, its current task has been brought to the front

解析:因为你的模拟器或真机中还有相同的app在运行,也就是你要运行的activity已经有一个在运行了。
在模拟器或真机中把此app停止运行即可

9、Android中模拟器如何访问本地服务器

今天在项目中涉及到Android中的模拟器如何访问服务器。个人采用本地服务器来进行调试,部署在Tomcat服务器中。
我们在Android模拟器当中如何才能访问到本地的服务器呢?
有的童鞋可能会想:
采用 localhost 或者 127.0.0.1 来访问。但这样访问是不成功的。

android模拟器(simulator)把它自己作为了localhost,也就是说,代码中使用localhost或者127.0.0.1来访问,都是访问模拟器自己!
若你想在模拟器simulator上面访问你的电脑,那么就使用android内置的IP: 10.0.0.2,
10.0.0.2是模拟器设定的特定ip,是你电脑的别名,在模拟器上用 10.0.0.2 就能成功访问你的电脑本机。

http://blog.csdn.net/cjjky/article/details/6525163