Hey everyone! I’m stuck with a weird issue in my Android app that uses the Spotify API. Everything works fine on the emulator but I’m hitting a snag on my actual phone.
When I try to play a song after user authentication on my phone, I get an INVALID_APP_ID error. Oddly enough, if I uninstall the Spotify app from my phone, my app works without crashes.
I’ve followed the Spotify API tutorial to set up the connection. Here’s a snippet of my authentication code:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == MY_REQUEST_CODE) {
val response = AuthenticationClient.getResponse(resultCode, data)
if (response.type == AuthenticationResponse.Type.TOKEN) {
val playerConfig = Config(this, response.accessToken, MY_CLIENT_ID)
SpotifyPlayer.create(playerConfig, object : SpotifyPlayer.InitializationObserver {
override fun onInitialized(player: SpotifyPlayer) {
spotifyPlayer = player
spotifyPlayer.addConnectionStateCallback(this@MainActivity)
spotifyPlayer.addPlayerNotificationCallback(this@MainActivity)
}
override fun onError(error: Throwable) {
Log.e(TAG, "Player init failed: ${error.message}")
}
})
}
}
}
Any ideas on how to fix this? Thanks in advance!