How to implement guide with exoplayer not releasing resources properly after activity destruction on android 14
Hey everyone, I'm running into an issue that's driving me crazy... This might be a silly question, but I'm updating my dependencies and I've searched everywhere and can't find a clear answer... I'm relatively new to this, so bear with me. I'm working with a question where ExoPlayer doesn't seem to release its resources correctly when the activity is destroyed. I have an Activity with a simple video player setup using ExoPlayer, and when I navigate away from this activity, the memory usage spikes significantly, even after the activity is destroyed. Here's a snippet of how I'm managing the ExoPlayer instance: ```kotlin class VideoPlayerActivity : AppCompatActivity() { private var exoPlayer: SimpleExoPlayer? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_video_player) initializePlayer() } private fun initializePlayer() { exoPlayer = SimpleExoPlayer.Builder(this).build() val mediaItem = MediaItem.fromUri(videoUri) exoPlayer?.setMediaItem(mediaItem) exoPlayer?.prepare() exoPlayer?.playWhenReady = true } override fun onStop() { super.onStop() releasePlayer() } private fun releasePlayer() { exoPlayer?.release() exoPlayer = null } } ``` Despite calling `release()` in the `onStop()` method, I've noticed that the memory footprint remains high, and I receive the following warning in the logcat: `E/ExoPlayer: Release failed: Player is not prepared.` It's as if the player is in a state where it want to release correctly. I’ve tried implementing `onPause()` and `onDestroy()` to call `releasePlayer()` as well, but the scenario continues. I also ensured that the player is not being referenced from anywhere else in the code. Is there something specific about ExoPlayer or its lifecycle I might be missing? Any advice on how to properly manage the lifecycle of ExoPlayer would be greatly appreciated. My development environment is Linux. Any help would be greatly appreciated! Thanks in advance! Am I missing something obvious? My team is using Kotlin for this desktop app. Has anyone dealt with something similar?