lingochamp / okdownload

A Reliable, Flexible, Fast and Powerful download engine.
Apache License 2.0
5.19k stars 773 forks source link

Attempt to invoke interface method 'void com.android.okhttp.internal.http.HttpStream.writeRequestHeaders(com.android.okhttp.Request)' on a null object reference #221

Open ghost opened 5 years ago

ghost commented 5 years ago

OkDownload Version

v1.0.6-SNAPSHOT

Problem Describe

I occur some problem, I also search on baidu and google, I even checked the source code, but it can't help, so my real problem is:...

Log

Attempt to invoke interface method 'void com.android.okhttp.internal.http.HttpStream.writeRequestHeaders(com.android.okhttp.Request)' on a null object reference java.lang.NullPointerException: Attempt to invoke interface method 'void com.android.okhttp.internal.http.HttpStream.writeRequestHeaders(com.android.okhttp.Request)' on a null object reference at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:593) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:471) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:244) at com.liulishuo.okdownload.core.connection.DownloadUrlConnection.release(DownloadUrlConnection.java:153) at com.liulishuo.okdownload.core.download.ConnectTrial.executeTrial(ConnectTrial.java:106) at com.liulishuo.okdownload.core.download.BreakpointRemoteCheck.check(BreakpointRemoteCheck.java:100) at com.liulishuo.okdownload.core.download.DownloadCall.execute(DownloadCall.java:170) at com.liulishuo.okdownload.core.NamedRunnable.run(NamedRunnable.java:32) at com.liulishuo.okdownload.core.dispatcher.DownloadDispatcher.syncRunCall(DownloadDispatcher.java:369) at com.liulishuo.okdownload.core.dispatcher.DownloadDispatcher.execute(DownloadDispatcher.java:183) at com.liulishuo.okdownload.DownloadTask.execute(DownloadTask.java:535) at android.view.View.performClick(View.java:6312) at android.view.View$PerformClick.run(View.java:24811) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:171) at android.app.ActivityThread.main(ActivityThread.java:6651) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)

gindoc commented 5 years ago

the same problem with me, maybe you should implement "com.liulishuo.okdownload:okhttp:@{you version}"

wangier commented 5 years ago

I got the same problem. It was resolved by adding all the dependencies in gradle file :

implementation 'com.liulishuo.okdownload:okdownload:1.0.5'
implementation 'com.liulishuo.okdownload:okhttp:1.0.5'
implementation 'com.liulishuo.okdownload:okhttp:1.0.5'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'