Marshmallow抛出FileNotFoundException,但旧版本没有

时间:2016-04-29 01:58:10

标签: php android android-asynctask filenotfoundexception

我一直在我的Galaxy Tab 4上测试我的应用程序没有任何问题,但是当我想在我的Galaxy S7上测试我的应用程序时,它会抛出FileNotFoundException。起初我认为它与运行时权限有关,但INTERNET未列为危险,因此这不是问题。

我有一个名为DatabaseTask的自定义类来处理我的数据库任务。此类扩展AsyncTask,因此这3个任务将在不同的线程上运行。现在奇怪的是,当我只调用我的任务只是将一些信息上传到我的数据库时,它工作正常,但当我尝试调用2个应该将图像上传到我的数据库的任务时,应用程序将抛出该异常我的S7(6.0),但不是我的Tab 4(4.4.1)。我没有从我的PHP脚本中得到任何错误,但似乎我的S7只是没有首先到达上传图像的php文件,而它确实到我的提交信息php文件。

在启用了所有3个任务的情况下从我的S7登录:

04-29 03:51:40.280 5569-5569/interfashionadmin.theindiestudio.com.interfashionadmin D/ViewRootImpl: ViewPostImeInputStage processPointer 0
04-29 03:51:40.350 5569-5569/interfashionadmin.theindiestudio.com.interfashionadmin D/ViewRootImpl: ViewPostImeInputStage processPointer 1
04-29 03:51:40.760 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 03:51:40.760 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 03:51:41.490 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: imagename=various_6_1&base64=<omitted>
04-29 03:53:45.220 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err: java.io.FileNotFoundException: http://url/script.php //edited out for privacy reasons!
04-29 03:53:45.220 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:242)
04-29 03:53:45.220 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at interfashionadmin.theindiestudio.com.interfashionadmin.DatabaseTask.doInBackground(DatabaseTask.java:168)
04-29 03:53:45.220 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at interfashionadmin.theindiestudio.com.interfashionadmin.DatabaseTask.doInBackground(DatabaseTask.java:26)
04-29 03:53:45.230 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
04-29 03:53:45.230 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-29 03:53:45.230 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
04-29 03:53:45.230 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-29 03:53:45.230 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-29 03:53:45.230 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.lang.Thread.run(Thread.java:818)
04-29 03:53:45.230 5569-5569/interfashionadmin.theindiestudio.com.interfashionadmin D/AndroidRuntime: Shutting down VM
04-29 03:53:45.230 5569-5569/interfashionadmin.theindiestudio.com.interfashionadmin E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                                      Process: interfashionadmin.theindiestudio.com.interfashionadmin, PID: 5569
                                                                                                      java.lang.NullPointerException: println needs a message
                                                                                                          at android.util.Log.println_native(Native Method)
                                                                                                          at android.util.Log.e(Log.java:334)
                                                                                                          at interfashionadmin.theindiestudio.com.interfashionadmin.DatabaseTask.onPostExecute(DatabaseTask.java:233)
                                                                                                          at interfashionadmin.theindiestudio.com.interfashionadmin.DatabaseTask.onPostExecute(DatabaseTask.java:26)
                                                                                                          at android.os.AsyncTask.finish(AsyncTask.java:651)
                                                                                                          at android.os.AsyncTask.access$500(AsyncTask.java:180)
                                                                                                          at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
                                                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                                          at android.os.Looper.loop(Looper.java:158)
                                                                                                          at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
04-29 03:53:45.730 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 03:53:45.730 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 03:53:46.440 5569-5579/interfashionadmin.theindiestudio.com.interfashionadmin W/art: Suspending all threads took: 17.722ms
04-29 03:53:46.440 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: imagename=various_6_2&base64=<omitted>
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err: java.io.FileNotFoundException: http://url/script.php //edited out for privacy reasons!
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:242)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at interfashionadmin.theindiestudio.com.interfashionadmin.DatabaseTask.doInBackground(DatabaseTask.java:168)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at interfashionadmin.theindiestudio.com.interfashionadmin.DatabaseTask.doInBackground(DatabaseTask.java:26)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin W/System.err:     at java.lang.Thread.run(Thread.java:818)
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 03:55:50.840 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 03:55:50.940 5569-5636/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: type=various&item=6&brand=brand&price=100&dscr=descr
04-29 03:58:45.400 5569-5569/interfashionadmin.theindiestudio.com.interfashionadmin I/Process: Sending signal. PID: 5569 SIG: 9

在启用了所有3个任务的情况下从我的选项卡4中记录:

04-29 04:14:59.346 21663-21663/interfashionadmin.theindiestudio.com.interfashionadmin D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
04-29 04:14:59.946 21663-21762/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 04:14:59.956 21663-21762/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
04-29 04:15:00.936 21663-21762/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: imagename=various_6_1&base64=<omitted>
04-29 04:15:03.216 21663-21663/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: succes&various_6_1 has been uploaded
04-29 04:15:03.606 21663-21762/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 04:15:04.296 21663-21678/interfashionadmin.theindiestudio.com.interfashionadmin I/art: Background sticky concurrent mark sweep GC freed 138344(3MB) AllocSpace objects, 23(2MB) LOS objects, 15% free, 29MB/35MB, paused 5.675ms total 39.248ms
04-29 04:15:04.336 21663-21762/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: imagename=various_6_2&base64=<omitted>
04-29 04:15:05.166 21663-21663/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: succes&various_6_2 has been uploaded
04-29 04:15:05.176 21663-21880/interfashionadmin.theindiestudio.com.interfashionadmin I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
04-29 04:15:05.216 21663-21880/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: type=various&item=6&brand=brans&price=100&dscr=descr
04-29 04:15:05.346 21663-21663/interfashionadmin.theindiestudio.com.interfashionadmin E/DatabaseTask: succes&item added!

谢谢!

1 个答案:

答案 0 :(得分:0)

只是让你知道我发现了问题。事实证明它毕竟与连接无关,但我想在尝试将我的位图编码为Base64字符串时耗尽时间。我使用以下行来做到这一点:bitmap.compress(Bitmap.CompressFormat.JPEG,100,Stream);.我猜我的S7拍摄的照片很大,它的质量设置为100,但当我把它降到25时,它就像一个魅力。这也解释了为什么只有我的标签4的前置摄像头(质量较低)工作。我认为这必须对图像路径做些什么。