I have
BeatPlayer.kt
interface BeatPlayer {
fun getSession(): MediaSessionCompat
fun playSong(extras: Bundle = bundleOf(BY_UI_KEY to true))
fun playSong(id: Long)
fun playSong(song: Song)
}
class BeatPlayerImplementation(
private val context: Application,
private val musicPlayer: AudioPlayer,
private val songsRepository: SongsRepository,
private val queueUtils: QueueUtils,
private val audioFocusHelper: AudioFocusHelper
) : BeatPlayer {
.........
}
MusicService.kt
@AndroidEntryPoint
class MusicService : CoroutineService(Main) {
@Inject
lateinit var beatPlayer: BeatPlayer
}
When I run it says:
[Dagger/MissingBinding] BeatPlayer cannot be provided without an @Provides-annotated method.
So I added this:
@Module
@InstallIn(SingletonComponent::class)
abstract class StorageModule {
@Singleton
@Binds
abstract fun bindBeatPlayer(beatPlayer: BeatPlayer): BeatPlayerImplementation
}
Now, I run, it says:
error: @Binds methods' parameter type must be assignable to the return type hilt
How to do it properly?