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

原文地址:http://blog.163.com/smilecatflower_18z/blog/static/1926270452011102523921331/

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可
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"
以下是英文说明:
  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"
  7. 来自逆流的鱼的百度空间
  8. 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() 
5.Activity XXXX(项目名) has leaked ServiceConnection 
 解决方法:
在onDestory方法里解除绑定服务就ok,解除绑定后服务还是可以运行的。
@Override
        protected void onDestroy() {
                // TODO Auto-generated method stub         
                this.unbindService(conn);
                super.onDestroy();
        }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值