Android开发中遇到的常见错误
R.java消失或解析异常
解决方法:查看res中资源文件,图片,xml等。比如图片文件名不能有大写不能有空格。解决错误之后执行Project->clean就可以了。
Unable to resolve target ‘android-2.14’
安装低版本的api,再default.properties 这个文件中把target=android-2.14 改成 target=android-7就没有问题了。
ActivityManager: Warning: Activity not started, its current task has been brought to the front
解决方法:该手机已经启动了相同名字的应用,关闭之后再试.使用Intent时出现另一个活动未发现的异常(ActivityNotFoundException)
解决方法:在AndroidManifest.xml中再加一个Couldn’t read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.编程的中途改变表的字段,实际字段并没有改变
解决方法:写对大小写或卸载当前版本,再安装调试。首次进入带有EditText的Activity不自动弹出软键盘,再次点击才弹出。
解决方法:只有设置manifest的方法有用,在activity的设置中添加:
[html] view plaincopyprint?
android:windowSoftInputMode="adjustPan|stateHidden"
7.启动android模拟器时候如果提示:Failed to install on device ‘emulator-5554′: timeout
解决方法:eclipse -> window -> Preferences -> Android -> DDMS -> ADB connection time out(ms).把这个时间设置的长一些,默认是5秒即5000ms, 我改成10秒就ok了。
这样就不用每次重启模拟器了。
8.No Launcher activity found!
The launch will only sync the application package on the device!
解决方法:在AndroidManifest.xml 中添加
<category android:name=”android.intent.category.LAUNCHER” />
9.
图片显示信息为:Android SDK要求ADT(Android Developer Toolkit)版本在20.0.0或以上版本,检测到当前版本为18.0.0,请更新最新的ADT。
出现这样的提示,根本原因是Eclipse启动时检测E:Program Filesandroid-sdk-windowstoolslibplugin.prop文件 文件内容为:
plugin.version=20.0.0
# end plugin.prop
这时候我们只需要改成:
plugin.version=18.0.0
# end plugin.prop
再重新启动下Eclipse,就解决了这个问题。
10.修改了Android项目的最小SDK版本之后出现很多stysle文件找不到
解决方法:compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "net.mmloo2014.android"
minSdkVersion 14
targetSdkVersion 23
}
compileSdkVersion 是多少版本的
那么compile ‘com.android.support:appcompat-v7:23.2.1’ 就是什么版本的。