刚出炉的小菜鸡,求各位大佬们帮忙解决我这个闪退的问题,闪退后报了如下的错。
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.yjt.browser, PID: 3632
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3, result=-1, data=null} to activity {com.yjt.browser/com.yjt.browser.CramerProActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4284)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4327)
at android.app.ActivityThread.-wrap22(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1624)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6531)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
at com.yjt.browser.CramerProActivity.saveMyBitmap(CramerProActivity.java:851)
at com.yjt.browser.CramerProActivity.onActivityResult(CramerProActivity.java:792)
at android.app.Activity.dispatchActivityResult(Activity.java:7188)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4280)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4327)
at android.app.ActivityThread.-wrap22(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1624)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6531)
at java.lang.reflect.Method.invoke(Native Method)
回复讨论(解决方案)
空指针嘛,data为null,不知道你的拍照代码是什么,Android版本时多少。拍照最后用output方式,传入文件路径,需要文件权限,如果是6.0以上还要动态请求权限,7.0以上如果要剪切还要实现文件共享权限。
1、E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
文件没有找到。加个文件是否存在的判断,如果存在则调用decode。
2、java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
空指针异常,bitmap为null就不能调用compress方法。加个判断if(bm!=null){bm.compress...}
1、E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
文件没有找到。加个文件是否存在的判断,如果存在则调用decode。
2、java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
空指针异常,bitmap为null就不能调用compress方法。加个判断if(bm!=null){bm.compress...}
我也遇到过这种,应该是android 7.0 的系统吧,参考一楼,一楼正解
6.0权限问题 7.0 creatFile问题
还有bitmap返回的时候为空。
我博客里面有说 你自己点进去看看
1、E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
文件没有找到。加个文件是否存在的判断,如果存在则调用decode。
2、java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
空指针异常,bitmap为null就不能调用compress方法。加个判断if(bm!=null){bm.compress...}
http://blog.csdn.net/xifengwanzhao/article/details/53587234
1、E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/ED66-110F/upload/2017-06-20-155054.jpeg (No such file or directory)
文件没有找到。加个文件是否存在的判断,如果存在则调用decode。
2、java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
空指针异常,bitmap为null就不能调用compress方法。加个判断if(bm!=null){bm.compress...}
http://blog.csdn.net/xifengwanzhao/article/details/53587234 我这里解决了几个粗心的小问题就没闪退了1.一开始写相片命名的时候是有固定格式的,后面相片命名是以时间戳的格式,然后文件找不到。2.自定义的相片路径被我不小心弄到调用相机拍照之后去了,拍出的相片没内容。相片没内容当然获取的值就是为空咯
6.0权限问题 7.0 creatFile问题
还有bitmap返回的时候为空。
我博客里面有说 你自己点进去看看 问题已经解决了,不过我的SDK版本是19的喔