Issue
I am developing an Android application, using ExoPlayer for video playback, Glide for image display, and a download library for file download, and they all have NullPointerException related to HttpURLConnection, I'm sure the link used is available.
The magic is, I just follow these library's The method described in the official documentation loads the data normally, and this error occurs from time to time, and the three libraries may not throw NullPointerException at the same time, and I don't even know how to reproduce this problem.
This is the error thrown by ExoPlayer, which prevents the video from loading:
E/LoadTask: Unexpected exception loading stream
java.lang.NullPointerException: wrapped.getHeaderField(key) must not be null
at com.android.tools.appinspection.network.httpurl.TrackedHttpURLConnection.getHeaderField(TrackedHttpURLConnection.kt:317)
at com.android.tools.appinspection.network.httpurl.HttpsURLConnectionWrapper.getHeaderField(HttpsURLConnectionWrapper.kt:182)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.isCompressed(DefaultHttpDataSource.java:829)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:413)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1009)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
The video playback part of the code is as follows:
val factory = ProgressiveMediaSource.Factory(
DefaultHttpDataSource.Factory()
)
val mediaSource = arrayListOf<MediaSource>(
factory.createMediaSource(MediaItem.fromUri(video.base_url)),
factory.createMediaSource(MediaItem.fromUri(audio.base_url))
)
val media = MergingMediaSource(true, *mediaSource.toTypedArray())
ViewModel.getPlayer()?.let { player ->
player.setMediaSource(media)
player.prepare()
}
And this is the error thrown by Aria, which cause software to crash:
E/AndroidRuntime: FATAL EXCEPTION: pool-5-thread-2
Process: io.github.sgpublic.bilidownload, PID: 22400
java.lang.NullPointerException: wrapped.getRequestProperty(field) must not be null
at com.android.tools.appinspection.network.httpurl.TrackedHttpURLConnection.getRequestProperty(TrackedHttpURLConnection.kt:235)
at com.android.tools.appinspection.network.httpurl.HttpsURLConnectionWrapper.getRequestProperty(HttpsURLConnectionWrapper.kt:274)
at com.arialyy.aria.http.ConnectionHelp.setConnectParam(ConnectionHelp.java:146)
at com.arialyy.aria.http.download.HttpDFileInfoTask.run(HttpDFileInfoTask.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
I have tried Invalidate and Restart, and even uninstalled and reinstalled Android Studio completely, but the problem still cannot be solved, so what is the problem?
Solution
I found the related entry, and to sum it up this is a bug in the TrackedHttpURLConnection implementation, the fix will be capped around mid-late March.
Answered By - Madray Haven
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.