在调试中出的错误及解答
来源:互联网 发布:淘宝纸箱设备 编辑:程序博客网 时间:2024/06/15 14:51
1.R.java不能实时更新
问题描述:在res文件中新增的变量不能在R.java中实时的显示出来。
解决方法:选择菜单栏的“Project”,勾选“Build Automatically”选项。
2.LogCat视窗没有显示
问题描述:在Eclipse的右下方没有显示LogCat视窗。
解决方法:选择菜单栏的“Windows”,再选择“Show View”,最后再选择“LogCat”即可。
3.编译时提示“android library projects cannot be launched”错误的解决方法
问题描述:编译时提示“android library projects cannot be launched”错误
解决方法:选择菜单栏的“Project”,再选择“Properties”,在弹出的窗口中选择“Android”,将is library选项前面的勾去掉。
4.在xml中添加EditText控件后提示“This text field does not specify an inputType or a hint”错误
问题描述:在xml中添加EditText控件,控件信息如下。
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" ></EditText>
编译时,提示“This text field does not specify an inputType or a hint”错误。
原因分析:控件中缺少android:hint以及android:inputType信息。android:hint用于设置EditText为空时显示的默认文字提示信息。android:inputType用于设置EditText的文本的类型,用于帮助输入法显示合适的键盘类型。
解决方法:在控件中添加android:hint以及android:inputType信息,添加后的控件信息如下。
<EditText
android:id="@+id/editText"
android:hint="0"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content" ></EditText>
5.警告信息“Hardcoded string "xxx", should use @string resource”的消除方法
问题描述:在xml中添加Button控件,控件信息如下。
<Button
android:id="@+id/mButton_mc"
android:text="mc"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</Button>
编译时,提示“Hardcoded string "mc", should use @string resource”警告。
原因分析:在android:text中使用到了字符串mc,应该将该字符串定义在String.xml中,然后再通过调用String.xml中该字符串的资源名来使用该字符串资源。这样做的好处在于可以做到一改全改,并且在支持多语言时也是很有用处的。
解决方法:在项目目录下的res-->values-->String.xml中添加字符串mc的信息如下。
<resources>
<string name="mc">mc</string>
</resources>
然后,再在使用该Button控件的xml中,通过调用该字符串的资源名来使用该字符串,如下。
<Button
android:id="@+id/mButton_mc"
android:text="@string/mc"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</Button>
6.警告信息“Nested weights are bad for performance”的消除方法
原因分析:在布局进行嵌套使用时,父布局与子布局都使用了android:layout_weight,但不是必须使用时,便会出现如题所示的警告信息。
解决方法:根据实际情况,去除子布局中非必须使用的android:layout_weight。
7.启动模拟器时出现错误信息“Please ensure that adb is correctly located at:XXXXX”的解决方法
现象:使用正确的源代码,在启动模拟器时出现如下错误信息“Please ensure that adb is correctly located at 'D:\AndroidSDK4.0\android-sdk-windows\platform-tools\adb.exe' and can be executed.”
解决方法:将D:\AndroidSDK4.0\android-sdk-windows\platform-tools加入到系统环境变量PATH中。
8.模拟器启动时一直显示信息“Waiting for HOME ('android.process.acore') to be launched...”的解决方法
现象:模拟器启动时,等很久(5分钟以上)也启动不了,一直提示“Waiting for HOME ('android.process.acore') to be launched...”信息。
解决方法:删除当前的模拟器,重新创建一个模拟器。
- 在调试中出的错误及解答
- JLex中一个莫名的错误...及解答
- 在使用suipack过程中出的错误
- xml文件在Myeclipse中出错误
- JRTPLIB在WINDOWS下的编译及相关错误调试
- postgresql易出的错误及解决
- hibernate易出的错误及解决方法
- 在dreamweaver中使用javascript调试器出现的错误
- 在myeclipse中调试tomcat服务器遇到的错误
- 10个最常见的WordPress的错误及解答
- oracle中export出的文件在import后出现的错误
- 真机调试,升级iOS10,编译器出的两个错误。
- SPI总线的特点、工作方式及常见错误解答
- SPI总线的特点、工作方式及常见错误解答
- 在CU上整理的MySQL的常见问题及解答
- android在代码中为new出的控件设置ID及setId()异常
- 在进行ASP调试时,可能出现的错误及尝试解决办法
- php 在页面中调试错误(解决php错误500)
- 如何给UIView等控件用xib设置圆角属性
- 图像平滑
- C++中关于全局对象的初始化顺序
- layoutSubviews
- iOS 获取键盘的高度
- 在调试中出的错误及解答
- 23 种设计模式
- linux 容器(LXC) 第3章 命名空间(namespace) 简介
- 学习笔记--meta
- android的ViewPager实现伪循环效果
- cocos2d-js:使用热更新时的注意事项
- 剑指offer-006
- JavaScript中操作Mysql数据库实例
- atexit()函数登记顺序的的验证