How to fix error YouTubeInitializationResult.SERVICE_INVALID

I try use Youtube API in my Android App, my app looke like this:

protected void onCreate(Bundle savedInstanceState) {
  ytpv = (YouTubePlayerView) findViewById(;
  ytpv.initialize("this is my key", this);

  et = (EditText) findViewById(;

public void onInitializationFailure(Provider arg0,YouTubeInitializationResult arg1) {
 if(arg1 == YouTubeInitializationResult.DEVELOPER_KEY_INVALID)
     Toast.makeText(this, "Initialization Fail- key invalid", Toast.LENGTH_LONG).show();
 else if(arg1 == YouTubeInitializationResult.SERVICE_INVALID)
     Toast.makeText(this, "Initialization Fail- Service invalid", Toast.LENGTH_LONG).show();
 else if(arg1 == YouTubeInitializationResult.INVALID_APPLICATION_SIGNATURE)
     Toast.makeText(this, "Initialization Fail- invalid application", Toast.LENGTH_LONG).show();

public void onInitializationSuccess(Provider provider, YouTubePlayer player,boolean wasrestored) {
ytp = player;
Toast.makeText(this, "Initialization  Success", Toast.LENGTH_LONG).show();

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
 if(actionId == EditorInfo.IME_ACTION_GO ){
   if(ytp !=null){
 return false;

But when i install on my real device, I get a error : Initialization Fail- Service invalid I have no idea to fix this error. Let me hear your idea, thank you 🙂


The Android YouTube API docs at: includes this note:

Note: Users need to run version 4.2.16 of the mobile YouTube app (or higher) to use the API.

I was getting a similar error until I upgraded the version of the YouTube app on my testing device.

Source: stackoverflow