How to prevent Error inflating class com.google.android.exoplayer2.ui.PlayerView?
Asked Answered
N

0

7

Exoplayer2 is working fine in devices like Samsung, Vivo, Xiaomi, etc on both release and debug build. But when I have released my app on the play store, it is throwing errors on some devices like nexus, pixel phones.

Crashlytics showing this error: Caused by android.view.InflateException: 
Binary XML file line #11: Error inflating class com.google.android.exoplayer2.ui.PlayerView

I found some similar questions already raised about the same issue but nothing used for me. (I am using the default player without any customized) can anyone help me to fix this issue?

My code:

<com.google.android.exoplayer2.ui.PlayerView
      android:id="@+id/playerView"
      android:focusable="true"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
  />


 var player:SimpleExoPlayer?=null


  override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.pdf_view_normal)

       player = ExoPlayerFactory.newSimpleInstance(this)
       val mediaDataSourceFactory = DefaultDataSourceFactory(this, getUserAgent(this, "demo.smart.com"))

      val mediaSource = ProgressiveMediaSource.Factory(mediaDataSourceFactory)
                                        .createMediaSource(Uri.parse(""))

        with(player) {
               this!!.prepare(mediaSource, false, false)
               playWhenReady = true
                     }

        playerView.setShutterBackgroundColor(Color.TRANSPARENT)
        playerView.player = player
        playerView.requestFocus()

}


override fun onDestroy() {
     super.onDestroy()

        if(player!=null){
                player!!.stop()
         }
 }

Gradle

android{
   
    kotlinOptions {
        jvmTarget = "1.8"
    }
    ..

}


 implementation 'com.google.android.exoplayer:exoplayer:2.10.8'
 

All log for your reference

Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{demo.smart.com.Viewer}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.exoplayer2.ui.PlayerView

Caused by android.view.InflateException
Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.exoplayer2.ui.PlayerView
Northumbria answered 13/2, 2021 at 1:39 Comment(1)
have you find the solution? i'm getting the same issue inandroidx.media3:media3-exoplayerKruller

© 2022 - 2024 — McMap. All rights reserved.