Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Android destroy could craches the app #10

Open
JumBay opened this issue Aug 29, 2020 · 8 comments
Open

Android destroy could craches the app #10

JumBay opened this issue Aug 29, 2020 · 8 comments

Comments

@JumBay
Copy link

JumBay commented Aug 29, 2020

Hi,

In https://github.com/ingageco/capacitor-music-controls-plugin/blob/master/android/src/main/java/com/ingageco/capacitormusiccontrols/CapacitorMusicControls.java#L188, could you replace:

notification.destroy();

By

if (notification != null) {
   notification.destroy();
}

To avoid have the app crashes if notification is not defined.

Thanks for the great work.

@eamador
Copy link

eamador commented Sep 3, 2020

Hi @JumBay, that was done here https://github.com/ingageco/capacitor-music-controls-plugin/pull/8/files, it is merged already!

@ingageco
Copy link
Owner

ingageco commented Sep 4, 2020

@eamador is right - when i saw this last week, i thought the same thing. let me know if we are wrong, or if a something doesn't reflect the change (like npm).

@JumBay
Copy link
Author

JumBay commented Sep 4, 2020

When I was testing the plugin, calling CapacitorMusicControls.destroy() when controls weren't created yet would crash the app because notification was not defined. I can do another try but I guess it will do the same since there was no change in code so far.

@JumBay
Copy link
Author

JumBay commented Sep 4, 2020

I did test again and it still crashes on android, works on ios :

E/Capacitor: Serious error executing plugin
    java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99)
        at com.getcapacitor.Bridge$1.run(Bridge.java:521)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.ingageco.capacitormusiccontrols.MusicControlsNotification.destroy()' on a null object reference
        at com.ingageco.capacitormusiccontrols.CapacitorMusicControls.destroy(CapacitorMusicControls.java:191)
        at java.lang.reflect.Method.invoke(Native Method) 

@mlnisd
Copy link

mlnisd commented Jan 4, 2021

@JumBay I'm currently running into this issue myself. Are you still experiencing this or was there a fix/workaround?

@mlnisd
Copy link

mlnisd commented Jan 5, 2021

UPDATE: Fixed using fix at line 188. Also had to set a value of "" for:

  • artist
  • playIcon
  • pauseIcon
  • prevIcon
  • nextIcon
  • closeIcon
  • notificationIcon

even though these are optional?

@JumBay
Copy link
Author

JumBay commented Jan 5, 2021

@mlnisd I didn't try so far but I guess the issue is still there. I use my fork https://github.com/wako-app/capacitor-music-controls-plugin btw

@mlnisd
Copy link

mlnisd commented Jan 5, 2021

@ingageco Would it possible to merge the fix from @JumBay #12, fixes the error they mentioned above on Android

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants