title: Error occurred while initializing the youtube player when i upgrade target sdk to 30
body: <p>I had implemented Youtube API and everything works great</p>
  <p>but when I had upgraded</p>
  <p><code>compileSdkVersion 29</code><br />
  to
  <code>compileSdkVersion 30</code>
  and
  <code>targetSdkVersion 29</code>
  to
  <code>targetSdkVersion 30</code></p>
  <p>it gives me
  An error occurred while initializing the youtube player</p>
  <p>I tried to change my API key from <a href="https://console.developers.google.com/" rel="nofollow noreferrer">https://console.developers.google.com/</a> but it doesn't make sense
  And everything goes well when I set compileSdkVersion and targetSdkVersion again to 29</p>
  <p>Here is my Video Player Page Code:</p>
  <pre><code>package silver.yellow.yellowpamphletonline;
  import android.os.Bundle;
  import android.widget.Button;
  import com.google.android.youtube.player.YouTubeBaseActivity;
  import com.google.android.youtube.player.YouTubeInitializationResult;
  import com.google.android.youtube.player.YouTubePlayer;
  import com.google.android.youtube.player.YouTubePlayerView;
  
  public class VideoPlayer extends YouTubeBaseActivity {
      YouTubePlayerView videoPlayer;
      Button playButton;
      YouTubePlayer.OnInitializedListener onInitializedListener;
      boolean playing;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_video_player);
          videoPlayer = findViewById(R.id.videoPlayer);
          playButton = findViewById(R.id.play);
          playing = false;
          onInitializedListener = new YouTubePlayer.OnInitializedListener() {
              @Override
              public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
                  playButton.setOnClickListener(v-&gt;{
                      if(playing){
                          youTubePlayer.pause();
                          playing = false;
                          playButton.setText(&quot;Play&quot;);
                      }
                      else {
                          youTubePlayer.play();
                          playing = true;
                          playButton.setText(&quot;Pause&quot;);
                      }
  
                  });
                  
                  youTubePlayer.loadVideo(&quot;pr4OEPhwM3c&quot;);
                  playing = true;
                  playButton.setText(&quot;Pause&quot;);
                  youTubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);
              }
  
              @Override
              public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
  
              }
          };
          videoPlayer.initialize(VideoPlayerConfig.API_KEY,onInitializedListener);
      }
  }
  </code></pre>