ClassCastException: MediaMetadataRetriever cannot be cast to AutoCloseable


I tried to use MediaMetadataRetriever with Kotlin use:

MediaMetadataRetriever().apply {
    setDataSource(context, uri)
}.use {

But it gives me an error on Android 6 Marshmallow (23 API):

cannot be cast to java.lang.AutoCloseable

Why so?


MediaMetadataRetriever implements AutoCloseable since API level 29.

Answered By – sdex

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published