Android Question OkHttp v1.01 Error

Pendrush

Well-Known Member
Licensed User
Longtime User
I'm using httputils2service and OkHttp v1.01.
In live application I can see errors on android 5.x device in httputils2service in line job.success = success
Error (obfuscated release):
Attempt to write to field 'boolean com.xxxx.yyyy.httpjob._vvvvvvvvvvvvv5' on a null object reference
All errors come from android 5.x version (SDK 22).
My manifest :<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/>
For release I'm using android.jar 23.
In Google Analytics crash, a lot of errors like (on 4k active app installation)
ErrnoException (@httputils2service:_hc_responsesuccess:170) {main} - about 300 errors per day
NullPointerException (@httputils2service:_vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv0:142) {main} - about 150 errors per day
ErrnoException (@httpjob:_vvvvvvvvvvvv7:180) {main} - about 90 errors per day

Stack trace from Google Dev console:
========= 01 =========
(all errors are from Android 5.x)
java.lang.NullPointerException
at com.xxxx.yyyyy.httputils2service._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv0(httputils2service.java:142)
at com.xxxx.yyyyy.httputils2service._response_streamfinish(httputils2service.java:196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
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:5478)
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:875)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
at dalvik.system.NativeStart.main(Native Method)



========= 02 =========
(errors from Android 4.x and Android 5.x)
java.io.FileNotFoundException: /data/data/com.xxxx.yyyyy/files/tempdown/3: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:370)
at com.xxxx.yyyyy.httputils2service._hc_responsesuccess(httputils2service.java:170)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 15 more

I'm unable to reproduce errors on my devices, also try emulator (Genymotion) without success to reproduce any of these errors.

Can anyone help with errors or workarounds?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that the android.jar version used during compilation doesn't have any effect on the actual APK.

Is it possible that you are using the same HttpJob multiple times without dimming it again?

The second error (with the stack trace) means that it failed to open a stream in File.DirInternalCache. Normally it shouldn't happen.

You can try to add File.MakeDir(File.DirInternalCache, "") when your program starts.
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Is it possible that you are using the same HttpJob multiple times without dimming it again?
I have checked, I'm actually call sub like
B4X:
Private Sub DownX
    Dim job1 As HttpJob
    job1.Initialize("Job1", Me)
    job1.Download("http://www.example.com/down.zip")
    job1.GetRequest.Timeout = 180000
End Sub


The second error (with the stack trace) means that it failed to open a stream in File.DirInternalCache. Normally it shouldn't happen.
my temp folder is
B4X:
TempFolder = File.DirInternal & "/tempdown"
but before download I'm using
B4X:
If File.Exists(File.DirInternal & "/tempdown", "") = False Then
        File.MakeDir(File.DirInternal, "tempdown")
End If
I have same errors in previous app versions, so I have changed from TempFolder = File.DirInternalCache to TempFolder = File.DirInternal & "/tempdown". I have think maybe some cache cleaner cleans automatically downloaded files from cache. But got same error no mater where is temp folder.

EDIT:
I found one place where using job without dimming it.
 
Last edited:
Upvote 0
Top