android error

1、工程编译出错:

myproject/gen already exists but is not a source folder. Convert to a source folder or rename it
解决方法:
  1. Right click on the project and go to "Properties"
  2. Select "Java Build Path" on the left
  3. Open "Source" tab
  4. Click "Add Folder..."
  5. Check "gen" folder and click Ok and Ok again
  6. 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中添加。
-partition-size 128

在真机运行时:
需要在程序清单中添加一个属性:

<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.

  1. go through your code and insure you close all your cursors in a finally clause.
  2. 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




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值