title: Exoplayer builder gives error when back pressed and open video again
body: <p>I am using ExoPlayer to play videos. Everything is normal and working until back pressing.I am using recycler view. User is pressing an item to enter video.But when user back pressed and open another video or same video again, player builder gives the error below. I have never seen a solution about this on the net. And also I need to say that I am using the same builder method on the document.</p>
  <p>this is the error:</p>
  <pre><code>Process: com.example.exoplayer, PID: 19208
     java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/exoplayer2/source/ads/AdsMediaSource$MediaSourceFactory;
         at java.lang.Class.classForName(Native Method)
         at java.lang.Class.forName(Class.java:453)
         at java.lang.Class.forName(Class.java:378)
         at com.google.android.exoplayer2.source.DefaultMediaSourceFactory.loadDelegates(DefaultMediaSourceFactory.java:321)
         at com.google.android.exoplayer2.source.DefaultMediaSourceFactory.&lt;init&gt;(DefaultMediaSourceFactory.java:152)
         at com.google.android.exoplayer2.source.DefaultMediaSourceFactory.&lt;init&gt;(DefaultMediaSourceFactory.java:127)
         at com.google.android.exoplayer2.SimpleExoPlayer$Builder.&lt;init&gt;(SimpleExoPlayer.java:195)
         at com.google.android.exoplayer2.SimpleExoPlayer$Builder.&lt;init&gt;(SimpleExoPlayer.java:153)
         at com.example.exoplayer.MainActivity.initializePlayer(MainActivity.kt:193)
         at com.example.exoplayer.MainActivity.onStart(MainActivity.kt:70)
         at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1333)
         at android.app.Activity.performStart(Activity.java:6992)
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2780)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
         at android.app.ActivityThread.-wrap11(Unknown Source:0)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
         at android.os.Handler.dispatchMessage(Handler.java:105)
         at android.os.Looper.loop(Looper.java:164)
         at android.app.ActivityThread.main(ActivityThread.java:6541)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
      Caused by: java.lang.ClassNotFoundException: Didn't find class &quot;com.google.android.exoplayer2.source.ads.AdsMediaSource$MediaSourceFactory&quot; on path: DexPathList[[zip file &quot;/data/app/com.example.exoplayer-V2UiSJoFtK6lpPhAy-YB-g==/base.apk&quot;],nativeLibraryDirectories=[/data/app/com.example.exoplayer-V2UiSJoFtK6lpPhAy-YB-g==/lib/x86, /system/lib, /vendor/lib]]
         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
  
  </code></pre>
  <p>This is my initialize and release methods:</p>
  <p>initialize()</p>
  <pre><code>   private fun initializePlayerXml(currentXmlLink: String) {
         if (player == null) {
             val trackSelector = DefaultTrackSelector(this)
             trackSelector.setParameters(
                 trackSelector.buildUponParameters().setMaxVideoSizeSd()
             )
             player = SimpleExoPlayer.Builder(this)
                 .setTrackSelector(trackSelector)
                 .build()
  
         }
         if (player!!.bufferedPosition == 0L) {
             playButton.setImageResource(R.drawable.ic_pause)
         }
  
         playButton.setOnClickListener {
             if (player!!.isPlaying) {
                 player!!.pause()
                 playButton.setImageResource(R.drawable.ic_play)
             } else {
                 player!!.play()
                 playButton.setImageResource(R.drawable.ic_pause)
             }
  
  
         }
         val doubleClickForwardFun = DoubleClick(object : DoubleClickListener {
             override fun onSingleClickEvent(view: View?) {
  
             }
  
             override fun onDoubleClickEvent(view: View?) {
                 val currentPosition = player!!.currentPosition
                 player!!.seekTo(currentPosition + 10000)
             }
         })
  
         val doubleClickBackwardFun = DoubleClick(object : DoubleClickListener {
             override fun onSingleClickEvent(view: View?) {
  
             }
  
             override fun onDoubleClickEvent(view: View?) {
                 val currentPosition = player!!.currentPosition
                 player!!.seekTo(currentPosition - 10000)
             }
         })
  
  
         forwardButton.setOnClickListener {
             val currentPosition = player!!.currentPosition
             player!!.seekTo(currentPosition + 10000)
         }
         backwardButton.setOnClickListener {
             val currentPosition = player!!.currentPosition
             player!!.seekTo(currentPosition - 10000)
  
         }
         doubleClickBackward.setOnClickListener(doubleClickBackwardFun)
         doubleClickForward.setOnClickListener(doubleClickForwardFun)
  
         val mediaItem =
             MediaItem.Builder()
                 .setUri(currentXmlLink)
                 .setMimeType(MimeTypes.APPLICATION_MPD)
                 .build()
         player!!.addMediaItem(mediaItem)
         player!!.addMediaItem(mediaItem)
  
         playerView!!.player = player
         player!!.playWhenReady = playWhenReady
         player!!.seekTo(currentWindow, playbackPosition)
         playbackStateListener.let { player!!.addListener(it) }
         player!!.prepare()
     }
  
  </code></pre>
  <p>release()</p>
  <pre><code>
     private fun releasePlayer() {
         if (player != null) {
             player!!.removeListener(playbackStateListener)
             player!!.release()
             player!!.stop()
             player = null
         }
     }
  </code></pre>