Solution 1 :
I would check which version of Android you are targeting in your project.
That override for createAudioThumbnail()
was added in API v29. Check here for the documentation.
If you are targeting a lower API version you might need to do something like this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ThumbnailUtils.createAudioThumbnail(file, Size(THUMBSIZE, THUMBSIZE), null)
} else {
// Use the deprecated version for older devices.
ThumbnailUtils.createAudioThumbnail(filepath, MediaStore.Images.Thumbnails.MINI_KIND)
}
Problem :
Hey Recently I am working on Music Player project and I have cover mostly things but I am Stucked how to create the mp3 files thumbnails.I have tried this
final int THUMBSIZE = 64 ;
File file= new File(songpathll);
Bitmap bitmap = ThumbnailUtils.createAudioThumbnail(file, new Size(100,100),null);
this is showing error
java.lang.NoSuchMethodError: No static method createAudioThumbnail(Ljava/io/File;Landroid/util/Size;Landroid/os/CancellationSignal;)Landroid/graphics/Bitmap; in class Landroid/media/ThumbnailUtils; or its super classes (declaration of 'android.media.ThumbnailUtils' appears in /system/framework/framework.jar)
Comments
Comment posted by createAudioThumbnail
Comment posted by DikShU
28 That’s fine .
Comment posted by Joachim Sauer
What do you mean by “that’s fine”? You can’t use API 29 methods if your target SDK level is 28.
Comment posted by DikShU
i also tried the method below api level 29 thats also giving same error
Comment posted by developer.android.com/reference/android/media/…
If you are trying to add artwork to an MP3 file, we might be better off looking at
Comment posted by DikShU
I have set my minimum sdk version to 22 so that no error occurs and my target level is 28 .thats usually fine.
Comment posted by developer.android.com/reference/android/media/…
OK, so it looks like for your use case you can use this version of createAudioThumbnail:
Comment posted by Joachim Sauer
According to the docs,
Comment posted by bcpettifer
Well that is intriguing. I’m wondering if the most suitable thing then is to just use the
Comment posted by DikShU
i will try ThumbnailUtils.extractThumbnail and update you if it Works