2016-01-20 50 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