您的位置:首页 > 移动开发 > Android开发

android 开发中遇到的问题及解决方法

2012-01-31 17:20 411 查看

转自:http://blog.163.com/smilecatflower_18z/blog/static/1926270452011102523921331/

2011-11-25 14:46:12| 分类:

android | 标签:开发问题及解决
|字号大中小 订阅


1.导入含有第三方jar包的项目时,无法定位项目中的jar包,“This will not be added to the package."
解决方法:
右击项目--->BuildPath-->Configuration Build Path--> 选中右侧的”Libraries“标签-->选中带有红叉的jar包并Remove;
然后单击”Add JARs“,找到该jar包在本项目中的位置就可以了。
如果运行后出现”Could not find .apk“,可以重新导入项目就可以了。

关于Could not find xxx.apk可

参考:http://blog.csdn.net/johee/article/details/5521310
2.“gen already exists but is not a source folder. Convert to a source folder or rename it”
右击项目选"Properties"-->在左侧选中"Java Build Path"-->打开右侧的“Source”标签-->单击"Add
Folder..."-->在弹出的对话框中选中 "gen" ,点击ok,ok;
右击项目选"Andriod Tools" -->选中单击"Fix
Project Properties"
以下是英文说明:

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"

来自逆流的鱼的百度空间

http://hi.baidu.com/flash_fish/blog/item/0237e11dc86c529786d6b60b.html

3.ActivityManager:
java.lang.SecurityException: Permission Denial: starting Intent


最近在调试程序的时候经常出现ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10000000 cmp=com.xxxxx.xxxxx/.ui.xxxxxxx } from null (pid=-1, uid=-1) requires null的问题,困扰我好几天了,一开始只是认为权限的问题,跟了好久一直没有解决。
后来看到:
The java.lang.SecurityException you are seeing is because you may enter two entries pointing to same activity. Remove the second one and you should be good to go.
才发现这个Activity在Manifest文件里写了两份,去掉一份后,终于可以正常运行了。
注:此问题还会引起,在手机端点击程序图标时,会提示程序未安装在手机上。

http://hi.baidu.com/b__a__i__d__u/blog/item/645fe45c1537a05afbf2c0fa.html


4.java.lang.IllegalArgumentException: x + width must be <= bitmap.width()

调用截图方法时应用强制退出:
public Bitmap takeScreenShot(Activity activity){


//View是你需要截图的View

View view
= activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);

view.buildDrawingCache();
b1
= view.getDrawingCache();
//获取状态栏高度

Rect frame
=
new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight
= frame.top;
//获取屏幕长和高

int width
= activity.getWindowManager().getDefaultDisplay().getWidth();
//去掉标题栏

b
= Bitmap.createBitmap(b1,
0, statusBarHeight,
350, b1.getHeight()-statusBarHeight);

view.destroyDrawingCache();
return b; }

解决方法:
x + width must be <= bitmap.width()宽度超出了你要截的图的宽度~width改成b1.getWidth()
来自:http://topic.csdn.net/u/20111031/10/4472919e-4653-4d5f-b9ae-b66277823ee5.html
5.Activity XXXX(项目名) has leaked ServiceConnection
解决方法:
在onDestory方法里解除绑定服务就ok,解除绑定后服务还是可以运行的。

@Override

protected void onDestroy() {

// TODO Auto-generated method stub

this.unbindService(conn);

super.onDestroy();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐