Android Question An odd error now and again???

Peter Simpson

Expert
Licensed User
Longtime User
Hello All,
Now and again I get a strange error in the HttpUtils2Service (HttpUtils2 version 2.01) at line 40, Response.GetAsynchronously.....

B4X:
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
    Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), True, TaskId)
End Sub

It just happens now and again once in a blue moon, basically randomly. Does anybody have any ideas on what exactly the issue is apart from where it says (No such file or directory). I personally am not creating any files or folders on the fly.

What I'm doing is getting an image(png) from of the internet and inserting it directly into a bitmap.

java.io.FileNotFoundException: /data/data/com.simplysoftware.stardate/cache/4: open failed: ENOENT (No such file or directory)

at libcore.io.IoBridge.open(IoBridge.java:409)
at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:370)
at com.simplysoftware.stardate.httputils2service._hc_responsesuccess(httputils2service.java:186)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at anywheresoftware.b4a.BA$3.run(BA.java:319)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:393)
... 16 more


It maybe happening happening if JobDone is busy, but I'm not sure to hell you the truth.

Cheers...
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
How are you creating the location for TempFolder?

My File.DirInternalCache returns /data/data/com.stevel05.test/cache

Whereas you have cache/4 (according to the errormesage)

Are you creating a new folder in File.DirInternalCache or is that how it is returned?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
No of course, 4 is the TaskID.

Just thinking out loud, The help for File.DirInternalCache states that
This data will be deleted automatically when the device runs low on storage

Is your device low on storage? Could it be deleting it while the app is running? (I don't know if it will do that)
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
No of course, 4 is the TaskID.

Just thinking out loud, The help for File.DirInternalCache states that

Is your device low on storage? Could it be deleting it while the app is running? (I don't know if it will do that)

Hello @stevel05 , thanks for responding.
No it's impossible that the device is low on memory. It's my test Galaxy Nexus, There is nothing on it except for Android 4.3, and maybe 10 or so apps. The G-Nex is not my daily driver.

You know your stuff knowing that 4 was the TaskID. I only know that because when I tried debugging it, I spotted the number 4
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
@stevel05 I'll do some more checking, thank you. It just strange that it happens now and again, it works perfectly most of the time. I've disabled that particular feature (swapping to classic icons) in the app and released it. Once I find out what's causing this error, I can release the an update with this feature included.

I will check the forum for more information...
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Update:
I was still having the same problem, so I decided to download all 38 images(38.5k in total) from the website and save them in the File.DirAssets folder. That way I can bypass the internet connection altogether for retrieving images.

I found out that the problem happened more on my 4G(about 22Mb) mobile connection than my 100Mb broadband connection. It also happened even more on my 3.5g(H) connection. Saving the 38 images locally cured the problem 100%, well bypassed the problem anyway.

Thanks for all your help guys...
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…