2016-01-20 48 views
8

我目前正在执行Spotify API的Android应用程序。我有所有的代码连接我的应用程序使用教程,并一直在我的应用程序现在有一段时间了。在验证用户身份后,通过我的应用播放歌曲时,它完美地工作,即在我的模拟器上。当我将它切换到我的手机时,它不起作用,并在android响应中给了我一个INVALID_APP_ID错误。当我将手机中的Spotify卸载并尝试通过我的应用程序进行登录时,我可以在手机上播放音乐,而不会发生任何崩溃。所以我的问题是如何解决这个问题?这里是我的验证用户代码:Spotify API:INVALID_APP_ID

@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()); 
        } 
       }); 
      } 
     } 
    } 

回答

2

你需要去到您的Spotify的开发者设置和更新

Android包

提供您完整的包名即com.company.app 和相应构建变体的SHA1指纹。

您可以通过运行

./gradlew signingReport 

那里得到的指纹,你可以找到如结果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应用页面上的设置足以冲洗系统,这样就可以从你的设备登录。

+1

这正是发生在我身上的事情。我会尝试遵循thye说明并发布我的结果 – chntgomez