Android Spotify SDK throwing INVALID_APP_ID when app is installed

I’m building an Android application that uses the Spotify SDK for music playback. Everything works great when I test it on the Android emulator - user authentication completes successfully and songs play without issues.

However, when I run the same code on my physical device, I get an INVALID_APP_ID error during the authentication process. The weird part is that if I completely remove the official Spotify app from my phone, then my application works perfectly on the device too.

It seems like there’s some conflict between my app and the installed Spotify client. Has anyone encountered this before? What’s the proper way to handle this situation?

Here’s my authentication handling code:

@Override
protected void onActivityResult(int reqCode, int resCode, Intent data) {
    super.onActivityResult(reqCode, resCode, data);
    
    if (reqCode == AUTH_REQUEST_CODE) {
        AuthenticationResponse authResponse = AuthenticationClient.getResponse(resCode, data);
        if (authResponse.getType() == AuthenticationResponse.Type.TOKEN) {
            Config config = new Config(this, authResponse.getAccessToken(), app_client_id);
            accessToken = authResponse.getAccessToken();
            Spotify.getPlayer(config, this, new Player.InitializationObserver() {
                @Override
                public void onInitialized(Player spotifyPlayer) {
                    musicPlayer = spotifyPlayer;
                    musicPlayer.addConnectionStateCallback(MainActivity.this);
                    musicPlayer.addPlayerNotificationCallback(MainActivity.this);
                }
                
                @Override
                public void onError(Throwable error) {
                    Log.e("SpotifyAuth", "Player initialization failed: " + error.getMessage());
                }
            });
        }
    }
}

This happens because the Spotify SDK tries to communicate with the installed Spotify app through intent filters, but there can be authentication conflicts when your app ID doesn’t match what the client expects. I ran into this during development and found that the issue occurs when the installed Spotify app has a different signature or version than what your SDK configuration expects. You can work around this by adding a check in your authentication flow to detect if the official app is installed and then explicitly force the SDK to use web-based authentication instead of the native app flow. Add setShowDialog(true) to your authentication request builder - this bypasses the native app entirely and uses the web authentication flow even when Spotify is installed.

had this exact same issue last month! its actualy a known bug with spotify’s sdk when theres version conflicts. try updating your spotify app to latest version first, then clear cache of both apps. worked for me after pulling my hair out for days lol