capacitor-plugin-playlist icon indicating copy to clipboard operation
capacitor-plugin-playlist copied to clipboard

Options empty, resulting in no drawable icon?

Open thoasty-dev opened this issue 3 years ago • 5 comments

I was stuck on the issue, that android always crashed on loading a playlist, because there was not small icon set:

AndroidRuntime: java.lang.RuntimeException: Unable to start service org.dwbn.plugins.playlist.service.MediaService@e78b87b with Intent { act=com.devbrackets.android.playlistcore.start_service cmp=**.**.**/org.dwbn.plugins.playlist.service.MediaService (has extras) }: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=PlaylistCoreMediaNotificationChannel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x10 color=0x00000000 category=transport actions=3 vis=PUBLIC)

I dont know much about the icon system in android / capacitor / cordova, but it came down to these lines: (MediaImageProvider.ts:52 and following)

private val mipmapIcon: Int
  get() {
    Log.i("options", options.toString())
      // return R.mipmap.icon; // this comes from cordova itself.
      if (notificationIconId <= 0) {
          notificationIconId = fakeR.getId("drawable", options?.icon)
      }
      return notificationIconId
  }

When I log options at this point, its always an empty object, even though I set the options before like this as documented:

player.setOptions({
  verbose: true,
  options: {
    icon: 'ic_notification'
  }
})

Has anybody got this to work on android and can share their code?

Best regards

thoasty-dev avatar Feb 08 '22 10:02 thoasty-dev

Hi! Got the same issue yesterday and after short research found that there should be icon.png file into each drawable folder. drawable-icon

PavelShvets-dev avatar Feb 08 '22 11:02 PavelShvets-dev

BTW, notification icon could be easily generated here: https://romannurik.github.io/AndroidAssetStudio/icons-notification.html

PavelShvets-dev avatar Feb 08 '22 11:02 PavelShvets-dev

Thank you very much for your help and the link. I will try it out asap. Btw, the link is kinda bugged and leads to /issues/url

thoasty-dev avatar Feb 08 '22 11:02 thoasty-dev

Thank you very much for your help and the link. I will try it out asap. Btw, the link is kinda bugged and leads to /issues/url

Thanx, link fixed 🙂

PavelShvets-dev avatar Feb 08 '22 11:02 PavelShvets-dev

honestly this is maybe the oldest part in my codebase and i am not an expert on android neither. i got a "resource id" set there as well and have corresponding pngs in the drawable folder https://developer.android.com/guide/topics/resources/drawable-resource

what was the resolution? How can we improve docs ?

phiamo avatar Mar 27 '22 01:03 phiamo