question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException in TrackSelectionParameters$Builder

See original GitHub issue

ExoPlayer Version

2.17.1

Devices that reproduce the issue

Samsung Motorola Hisense

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

No

Reproduction steps

Unable to reproduce reported in Crashalytics

Expected result

Shouldn’t crash

Actual result

java.lang.NullPointerException
Attempt to invoke virtual method 'int android.os.Bundle.getInt(java.lang.String, int)' on a null object reference
com.google.android.exoplayer2.trackselection.TrackSelectionParameters$Builder.<init> (TrackSelectionParameters.java:156)
com.google.android.exoplayer2.trackselection.DefaultTrackSelector$ParametersBuilder.<init> (DefaultTrackSelector.java:189)
com.google.android.exoplayer2.trackselection.DefaultTrackSelector$ParametersBuilder.<init> (DefaultTrackSelector.java:107)
com.google.android.exoplayer2.trackselection.DefaultTrackSelector$Parameters.lambda$static$0 (DefaultTrackSelector.java:1214)
com.google.android.exoplayer2.trackselection.-$$Lambda$DefaultTrackSelector$Parameters$U98Wdd2EwvvSUOXBjakY0Uxo3EE.fromBundle (lambda) 
VideoFragment.onCreate (VideoFragment.java:192)
androidx.fragment.app.Fragment.performCreate (Fragment.java:2949)
androidx.fragment.app.FragmentStateManager.create (FragmentStateManager.java:475)
androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:278)
androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:2189)
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:2100)
androidx.fragment.app.FragmentManager.execSingleAction (FragmentManager.java:1971)
androidx.fragment.app.BackStackRecord.commitNow (BackStackRecord.java:305)
androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder (FragmentStateAdapter.java:341)
androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow (FragmentStateAdapter.java:276)
androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow (FragmentStateAdapter.java:67)
androidx.recyclerview.widget.RecyclerView.dispatchChildAttached (RecyclerView.java:7867)
androidx.recyclerview.widget.RecyclerView$5.addView (RecyclerView.java:893)
androidx.recyclerview.widget.ChildHelper.addView (ChildHelper.java:107)
androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt (RecyclerView.java:8902)
androidx.recyclerview.widget.RecyclerView$LayoutManager.addView (RecyclerView.java:8860)
androidx.recyclerview.widget.RecyclerView$LayoutManager.addView (RecyclerView.java:8848)
androidx.recyclerview.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1645)
androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1591)
androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:668)
androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:4309)
androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:4012)
androidx.recyclerview.widget.RecyclerView.onLayout (RecyclerView.java:4578)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
androidx.viewpager2.widget.ViewPager2.onLayout (ViewPager2.java:527)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild (CoordinatorLayout.java:1213)
androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild (CoordinatorLayout.java:899)
androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:919)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:396)
android.widget.FrameLayout.onLayout (FrameLayout.java:333)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.RelativeLayout.onLayout (RelativeLayout.java:1189)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:396)
android.widget.FrameLayout.onLayout (FrameLayout.java:333)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:2001)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1844)
android.widget.LinearLayout.onLayout (LinearLayout.java:1753)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:396)
android.widget.FrameLayout.onLayout (FrameLayout.java:333)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:2001)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1844)
android.widget.LinearLayout.onLayout (LinearLayout.java:1753)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:396)
android.widget.FrameLayout.onLayout (FrameLayout.java:333)
com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:2740)
android.view.View.layout (View.java:16953)
android.view.ViewGroup.layout (ViewGroup.java:5579)
android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2562)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2265)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1323)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:6718)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:894)
android.view.Choreographer.doCallbacks (Choreographer.java:696)
android.view.Choreographer.doFrame (Choreographer.java:631)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:880)
android.os.Handler.handleCallback (Handler.java:815)
android.os.Handler.dispatchMessage (Handler.java:104)
android.os.Looper.loop (Looper.java:207)
android.app.ActivityThread.main (ActivityThread.java:5765)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679) 

VideoFragment @192

if (savedInstanceState != null) { trackSelectorParameters = DefaultTrackSelector.Parameters.CREATOR.fromBundle( savedInstanceState.getBundle(KEY_TRACK_SELECTOR_PARAMETERS)); }

Media

Not Applicable

Bug Report

  • You will email the zip file produced by adb bugreport to dev.exoplayer@gmail.com after filing this issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
christostscommented, May 26, 2022

If I read your code snippets correctly, the issue is that you save the parameters as parcelable calling outState.putParcelable(...) and then you read the parameters as bundle calling savedInstanceState.getBundle() which returns null.

0reactions
ingsaurabhcommented, May 30, 2022

outState.putBundle(KEY_TRACK_SELECTION_PARAMETERS, trackSelectionParameters.toBundle());

Even after fixing that, frequency on crash is reduced but its still happening

Read more comments on GitHub >

github_iconTop Results From Across the Web

NULLPOINTEREXCEPTION DEPLOYING MESSAGE FLOW ...
The deploy fails with a NullPointerException message: BIP3701E: A Java exception was thrown whilst calling the Java JNI method ...
Read more >
Investigating a NullPointerException (How To) - Treehouse
We have an error! It's a common one: we have encountered an uncaught NullPointerException. Let's see how to investigate and fix it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found