react-native-track-player icon indicating copy to clipboard operation
react-native-track-player copied to clipboard

Fix: Correct onBind method signature to match android.app.Service in MusicService.kt

Open StuCodeGreen opened this issue 8 months ago • 5 comments

Summary

This PR fixes a Kotlin compilation error in MusicService.kt related to the onBind method signature.

Problem

The existing code attempted to override:

override fun onBind(intent: Intent?): IBinder

However, the Android Service class defines:

public abstract IBinder onBind(Intent intent)

Due to Kotlin's strict override checks, the mismatch causes:

'onBind' overrides nothing.

Fix Updated the signature to match the exact expected method:

@MainThread
override fun onBind(intent: Intent): IBinder {
    return binder
}

StuCodeGreen avatar Apr 13 '25 20:04 StuCodeGreen

+1 for now i adde dthe patch-package

AbdullahZareen avatar Apr 23 '25 17:04 AbdullahZareen

Would be great to get this approved and released if possible.

chriship avatar May 29 '25 09:05 chriship

2 months is a long time to sit on a pull request to remove a redundant question mark. This is blocking compatibility with Expo SDK 53 / React Native 0.79.

https://github.com/doublesymmetry/react-native-track-player/issues/2455

occultus73 avatar Jun 04 '25 22:06 occultus73

this might in turn breaks RN < 0.79, could someone test?

this is caused by the kotlin rewrite of HeadlessJsTaskService.

lovegaoshi avatar Jun 04 '25 23:06 lovegaoshi

@lovegaoshi All that question mark means in Kotlin is Intent is a nullable type. It's overwriting a java super method where Intent is not nullable. The only reason why this breaks RN 0.79 (at least with expo 53) is because they are using the latest Android plugins that are now super strict about nullable type mismatches. But obviously pretending a non-nullable is nullable is completely harmless, which is why it has been permitted by Android until now.

tl;dr this will absolutely not break RN < 0.79. It's just fixing a super (no pun intended!) pedantic typing error.

occultus73 avatar Jun 04 '25 23:06 occultus73

Sorry this has taken so long!

jspizziri avatar Jun 24 '25 18:06 jspizziri