Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Error cannot find symbol NotificationCompat.DecoratedMediaCustomViewStyle

I'm following android's documentation on creating a custom notification for media playback controls. I read that it was recommended to set the style of the notification to DecoratedMediaCustomViewStyle, however this gives me the following compilation error.

error: cannot find symbol class DecoratedMediaCustomViewStyle

I'm importing DecoratedMediaCustomViewStyle from android.support.v4.app.NotificationCompat. When I try and use DecoratedCustomViewStyle, my media playback buttons in my notification do not work. But when I exclude setting the style, then my buttons work but the notification isn't decorated with the large icon and title.

Any help is appreciated.

like image 526
Michael Avatar asked Dec 07 '18 00:12

Michael


3 Answers

This worked for me rather

import androidx.core.app.NotificationCompat; 

instead of android.support.v4.media.app.NotificationCompat OR android.support.v4.app.NotificationCompat

like image 166
Kofi Sammie Avatar answered Nov 12 '22 16:11

Kofi Sammie


I found it. I had to import from android.support.v4.media.app.NotificationCompat instead of android.support.v4.app.NotificationCompat.

like image 7
Michael Avatar answered Nov 12 '22 17:11

Michael


I have been getting this error for a npm package I use (/@aws-amplify/pushnotification) when assembling release build (./gradlew assembleRelease) in a react-native project.

Resolved with Jetifier, which can be done by:

yarn add jetifier --dev or npm install jetifier --save-dev

Then adding these to scripts in package.json:

  "postinstall": "jetify",
  "jetify": "npx jetify"

Then run yarn run jetifier or npm run jetifier

./gradlew clean && ./gradlew assembleRelease and build is successful. I assume androidx related issue.

like image 6
Dylan w Avatar answered Nov 12 '22 16:11

Dylan w