Android Studio Spotify App Remote SDK:CouldNotFindSpotifyApp错误

7uhlpewt  于 2023-04-07  发布在  Android
关注(0)|答案(1)|浏览(175)

我正在尝试构建一个集成了Spotify App Remote SDK的应用程序。但是,当我尝试使用SDK连接到Spotify时,即使设备上安装了Spotify应用程序,也会引发CouldNotFindSpotifyApp错误。
我在stackoverflow上找到了其他解决方案,它们要求我在清单中添加一个查询。

<queries>
    <package android:name="com.spotify.music" />
</queries>

”“可是那不行,我也犯了同样的错误。
我尝试使用以下代码连接到Spotify API:”

ConnectionParams connectionParams =
        new ConnectionParams.Builder(CLIENT_ID)
                .setRedirectUri(REDIRECT_URI)
                .showAuthView(true)
                .build();
SpotifyAppRemote.connect(this, connectionParams,
        new Connector.ConnectionListener() {

            @Override
            public void onConnected(SpotifyAppRemote spotifyAppRemote) {
                mSpotifyAppRemote = spotifyAppRemote;
                Log.d("MainActivity", "Connected! Yay!");

                // Now you can start interacting with App Remote
                connected();
            }

            @Override
            public void onFailure(Throwable error) {
                if (error instanceof NotLoggedInException || error instanceof UserNotAuthorizedException) {
                    Log.d("MainActivity", "Other Error");
                } else if (error instanceof CouldNotFindSpotifyApp) {
                    Log.d("MainActivity", "User Not Found");
                }
            }
        });


而不是连接它给了我一个错误

CouldNotFindSpotifyApp
wlzqhblo

wlzqhblo1#

找到解决办法了吗?
我正在使用Spotify SDK的应用程序工作.一些用户说我他们有同样的错误.经过分析,看来他们使用了国防部Spotify的APK.我认为这个国防部作为其他包添加<.queries>.
否则,我使用以下代码在Kotlin中建立连接:

private var mSpotifyAppRemote: SpotifyAppRemote? = null

connectionParams = ConnectionParams.Builder(Constants.CLIENT_ID_SPOTIFY)
        .setRedirectUri(Constants.REDIRECT_URI_SPOTIFY)
        .showAuthView(true)
        .build()

SpotifyAppRemote.connect(this, connectionParams,
        object : Connector.ConnectionListener {
            override fun onConnected(spotifyAppRemote: SpotifyAppRemote) {
                mSpotifyAppRemote = spotifyAppRemote

                mSpotifyAppRemote!!.getPlayerApi().play("spotify:playlist:" + playlist!!.id)

                mSpotifyAppRemote!!.playerApi.subscribeToPlayerState()
                    .setEventCallback { playerState: PlayerState ->
                        spotifyTrack = playerState.track
                    }
            }

            override fun onFailure(throwable: Throwable) {
                Log.e(TAG, throwable.message, throwable)

                // Something went wrong when attempting to connect! Handle errors here
            }
        })

相关问题