Android Question Error in HttpUtils2


Active Member
Licensed User
Longtime User
i use HttpUtils2 whith OKHttp....
In Firebase Crashanalytics i get an error:

Fatal Exception: java.lang.NullPointerException: Attempt to write to field 'boolean' on a null object reference
(if need more from Crashanalytics please ask)

The Code:
'HttpUtils2 version 2.10 (based on OkHttp library)
'Service module
Sub Process_Globals
 Private hc As OkHttpClient
 Private TaskIdToJob As Map
 Public TempFolder As String
 Private taskCounter As Int
End Sub

Sub Service_Create
 TempFolder = File.DirInternalCache
End Sub

Sub Service_Start (StartingIntent As Intent)
End Sub

Sub Service_Destroy
End Sub

Public Sub SubmitJob(job As HttpJob) As Int
 taskCounter = taskCounter + 1
 TaskIdToJob.Put(taskCounter, job)
 If job.Username <> "" And job.Password <> "" Then
  hc.ExecuteCredentials(job.GetRequest, taskCounter, job.Username, job.Password)
  hc.Execute(job.GetRequest, taskCounter)
 End If
 Return taskCounter
End Sub

Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
 ' ********** Modified Code für DownloadService (from Erel?)*************
 Dim CountStream As CountingOutputStream
 CountStream.Initialize(File.OpenOutput(TempFolder, TaskId, False))
 Response.GetAsynchronously("response", CountStream , True, TaskId)

' Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), True, TaskId)
End Sub

Sub Response_StreamFinish (Success As Boolean, TaskId As Int)
 If Success Then
  CompleteJob(TaskId, Success, "")
  CompleteJob(TaskId, Success, LastException.Message)
 End If
End Sub

Sub hc_ResponseError (Response As OkHttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
 If Response <> Null Then
 End If
 CompleteJob(TaskId, False, Reason)
End Sub

Sub CompleteJob(TaskId As Int, success As Boolean, errorMessage As String)
 Dim job As HttpJob = TaskIdToJob.Get(TaskId)
 job.success = success
 job.errorMessage = errorMessage
End Sub
Line 161 -> job.success = success
Line 179 -> CompleteJob(TaskId, False, Reason)

what/where is the Error and what can i do?


Active Member
Licensed User
Longtime User
Note that you are using an old version of OkHttpUtils2.
Never change a running System ;)
I will check to "update"

Are you doing anything special with HttpUtils2Service? Destroying it maybe?
No (i think)
Only the HttpJob Class (V2.01) use it. The HttpJob i use for
- Download (with (GetRequest.SetHeader)
- Download2
- PostBytes/PatchBytes (with GetRequest.SetHeader/SetContentType)
- PostString

For more information (e.g. the Android Version), I have to look later.
Upvote 0


Active Member
Licensed User
Longtime User
I only see once in the Firebase Crashanalytics Console (1 Event/1 User)
- Samsung Device
- Android 9

The latest version is included in the IDE.
For the Next Version I have switch to the "IDE Version"
Upvote 0