Spotify API:INVALID_APP_ID [英] Spotify API: INVALID_APP_ID
问题描述
我目前正在开发实现Spotify API的android应用.我已经使用教程将所有代码连接到我的应用程序以进行发现,并且已经在我的应用程序上工作了一段时间.验证用户身份后,当我通过我的应用播放歌曲时,它可以完美运行,即在我的模拟器上.当我将其切换到手机时,它无法正常工作,并在Android响应中给了我一个INVALID_APP_ID错误.当我从手机上卸载Spotify,然后尝试通过我的应用登录进行Spotify时,我便可以播放手机中的音乐,而不会发生任何崩溃.所以我的问题是我该如何解决?这是我用于验证用户身份的代码:
I am currently working on an android app which is implementing the Spotify API. I have all of the code connecting my app to spotify using the tutorial and have been working on my app for sometime now. When I play a song through my app after authenticating the user, it works perfectly, that is on my emulator. When I switch it over to my phone it didn't work and gave me an INVALID_APP_ID error in the android response. When I uninstalled spotify off my phone and then tried to login to spotify through my app, I was then able to play music from my phone without any crashes. So my question is how do I fix that? Here is my code for authenticating a user:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// Check if result comes from the correct activity
if (requestCode == requestcode) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
if (response.getType() == AuthenticationResponse.Type.TOKEN) {
Config playerConfig = new Config(this, response.getAccessToken(), client_id);
token = response.getAccessToken();
Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
@Override
public void onInitialized(Player player) {
mPlayer = player;
mPlayer.addConnectionStateCallback(.this);
mPlayer.addPlayerNotificationCallback(.this);
}
@Override
public void onError(Throwable throwable) {
Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage());
}
});
}
}
}
推荐答案
您需要转到Spotify开发人员设置并更新
You need to go to your Spotify developer settings and update the
Android软件包
Android Packages
提供完整的包裹名称,即com.company.app
以及相应的构建变体的SHA1指纹.
Providing your full package name i.e. com.company.app
and the SHA1 fingerprint of the respective build variant.
您可以通过运行
./gradlew signingReport
例如,您可以在其中找到结果debug
There you can find the results for e.g. debug
Variant: debug
Config: debug
Store: /Users/<your username>/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
SHA1: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
Valid until: Monday, August 29, 2046
在Spotify应用程序页面上保存设置足以刷新系统,以便您可以从设备登录.
Saving the settings on your Spotify app page is enough to flush the system so that you can login from your device.
这篇关于Spotify API:INVALID_APP_ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!