1、工程编译出错:
myproject/gen already exists but is not a source folder. Convert to a source folder or rename it
解决方法:
- Right click on the project and go to "Properties"
- Select "Java Build Path" on the left
- Open "Source" tab
- Click "Add Folder..."
- Check "gen" folder and click Ok and Ok again
- Again right click on the project and in the "Andriod Tools" click on "Fix Project Properties
2、运行时异常
Android error - Caused by: java.lang.NoClassDefFoundError: android.support.v4.util.
Right Click on your project -> Build Path -> Configure Build Path -> Order and Export Tab.
Make sure that "Android Private Libraries" is checked for Export.
记得还要clean一下所有关联的project。
3、烧录apk时出错:INSTALL_FAILED_INSUFFICIENT_STORAGE
http://suchang1123.blog.163.com/blog/static/2001940512011102553551469/
首先,我们要知道如果在运行一开始系统提示这个异常的时候,是因为机器内存的瓶颈,当apk大于我们的机器内存时,会抛出异常。因为我们在模拟器中曾经设置过模拟内存的大小
1(仅限apk小于机器内存,并且已安装上当前apk,只是无法再次debug)
启动模拟器,然后进入菜单
settings->applications->mange
applications-> select the application->select "unistall".
2 Eclipse中在项目Target的Options中添加。
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.learns" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0" >
4、java.lang.IllegalStateException: Couldn't init cursor window
今天遇到了这个问题,发生的情况是这样的。我一台手机里面有3000条彩信,遍历彩信的过程中,又开了几个cursor,仔细观察代码后发现又一个cursor用完后没有close掉,因此在遍历了几百次以后就抛出这个异常了。
解决方法是,每个cursor用完后要记得close掉。
http://stackoverflow.com/questions/12928708/android-java-lang-illegalstateexception-couldnt-init-cursor-window
this exception is thrown by the native code. (refer to this)
mainly it is due to failing to allocate memory for the new cursor being created. so my guess is that the data you are fetching sometimes get too too much (nearly more than 1M in memory) or you are opening lots of cursor without closing them untill you ran out of memory to allocate a new buffer.
- go through your code and insure you close all your cursors in a
finally
clause. - if the data being fetched from the database could go too large, get them in separate chunks (like doing a pull to fetch more in a list of something).
5、无法收到系统启动广播
android.permission.RECEIVE_BOOT_COMPLETED
查了很久才发现原来同事在manifest中加了这么一个坑爹的属性
android:installLocation="preferExternal"
6、关于启动模式为SingleTask再次启动无法传递Intent参数的问题。
解决方法:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
7、如下所示
public class APNSBroadcastReceiver extends BroadcastReceiver {
private APNSMessageProcessor msgProcessor = null;
@Override
public void onReceive(final Context context, Intent intent) {
LogPrint.debug("apns service send a broadcast that receive a msg!");
if (msgProcessor == null) {
msgProcessor = new APNSMessageProcessor(context);
}
}
}
我发现了每收到一个广播,msgProcessor都会被实例化一次。
8、javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
9、Viewpager 调用PagerAdapter调用notifyDataSetChanged没有作用
解决方法:重写getItemPosition方法即可
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
http://stackoverflow.com/questions/7263291/viewpager-pageradapter-not-updating-the-view
10、为eclipse设置Custom debug keystore时提示:Keystore was tampered with, or password was incorrect错误
解决方法如下:
Keystore password: "android"
Key alias: "androiddebugkey"
Key password: "android"
http://stackoverflow.com/questions/15754060/how-to-set-a-custom-keystore-for-debugging-in-eclipse-for-android
11、R.string.xxx进行string格式化
1、遇到如下错误的时候说明你需要在单引号签名加转义字符(\):
Description Resource Path Location Type error: Apostrophe not preceded by \ (in Search' Titles) strings.xml
只要将定义的字符串中的单引号('), 修改为(\')即可
2、变量文本格式(%s)提示:
Multiple annotations found at this line:
- error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false"
attribute?
- error: Unexpected end tag string
这是由于新的SDK(虽然从没用过老的)采用了新版本的aapt(Android项目编译器), 这个版本的aapt编译起来会比老版本更加的严格, 在Android最新的开发文档中描述String的部分,已经说明了如何去设置 %s 等符号, 可以点击去看.
简单解决方法就是:把%s之类的变量格式替换成%1$s, %1表示第一个位置的变量, $s表示为字符串类型
例如:
<string name="welcome_messages">Your First Var is %1$s! You Second Var is %2$d.</string>
12、mac下输出apk时的关于zipalign错误的解决方法
在mac下开发android应用时,在eclipse里导出app的时候有时会出现zipalign有关的错误提示:error while running zipalign,unable to open xx/xx/xx/xxx/xxx.apk as zip archive...。经过测试发现是因为编码不符造成的,只要在eclipse的ini文件里(我的路径是/Applications/development/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini)加入-Dfile.encoding=utf-8就可以解决。
13、关于gridview默认有个内边距的问题。
android:listSelector="@null"
http://stackoverflow.com/questions/6876861/removing-the-extra-padding-in-a-gridview-in-android