Search code examples
androidandroidx

error: cannot find symbol class MediaStyle after migrating to androidx


android.support.v4.media.app.NotificationCompat.MediaStyle() was working fine in a music player application but after migrating to android x I get this error: cannot find symbol class MediaStyle. Any help would be appreciated thanks.


Solution

  • In AndroidX, that specific style is located in a different package. You need to prepend the media style with 'androidx.media.app'.

    In other words:

    builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle());
    

    Curiously enough, I didn't need to implement this package in my gradle file, so it could be something related to AndroidX internal dependencies.