androidandroid-studioandroid-mediaplayer

Android Studio : lost MediaButtonReceiver library


After I left my project development sleep for a while, I had to get back to it.

I'm stuck with the loss of MediaButtonReceiver library ...

It used to sit in

android.support.v4.media.session.MediaButtonReceiver

However, V4 seems to have lost the media libs ... enter image description here

Then I try to turn to androidx, as per doc :

enter image description here

But no game ...

enter image description here

What am I missing ?


Solution

  • MediaButtonReceiver is provided by a library. If you don't add it to your gradle config then the classes won' be available. Check the MediaButtonReceiver web page.

    On the right there is the Artifact definition which defined the library the class is located in. Klicking it lead you to Media where you can read that you read that you have to add the following dependency to your gradle config:

    dependencies {
        implementation "androidx.media:media:1.7.0"
    }