title: main java.lang.RuntimeException: Unable to start activity ComponentInfo
body: <p>I'm trying to use YouTube API in my Android app. First - if I've added lib to my project should something in values appear?</p>
  
  <p>Second one is here, my error:</p>
  
  <p>Logcat:</p>
  
  <pre><code>E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.RuntimeException: Unable to start activity ComponentInfo{pl.krasiniak.krachapp_beta/pl.krasiniak.krachapp_beta.Studio}: java.lang.NullPointerException
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
              at android.app.ActivityThread.access$600(ActivityThread.java:132)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:4575)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
              at pl.krasiniak.krachapp_beta.Studio.onCreate(Studio.java:25)
              at android.app.Activity.performCreate(Activity.java:4465)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
              at android.app.ActivityThread.access$600(ActivityThread.java:132)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
              at android.os.Handler.dispatchMessage(Handler.java:99)
              at android.os.Looper.loop(Looper.java:137)
              at android.app.ActivityThread.main(ActivityThread.java:4575)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Studio.java (I've took it to test from one site)</p>
  
  <pre><code>    package pl.krasiniak.krachapp_beta;
  
  
      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;
      import com.google.android.youtube.player.YouTubePlayer.Provider;
  
      import android.os.Bundle;
      import android.widget.Toast;
  
      public class Studio extends YouTubeBaseActivity implements
      YouTubePlayer.OnInitializedListener{
  
  public static final String API_KEY = "blabla";
  public static final String VIDEO_ID = "o7VVHhK9zf0";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      YouTubePlayerView youTubePlayerView = (YouTubePlayerView)findViewById(R.id.youtube_view);
      youTubePlayerView.initialize(API_KEY, this);
  }
  
  @Override
  public void onInitializationFailure(Provider provider,
                                      YouTubeInitializationResult result) {
      Toast.makeText(getApplicationContext(),
              "onInitializationFailure()",
              Toast.LENGTH_LONG).show();
  }
  
  @Override
  public void onInitializationSuccess(Provider provider, YouTubePlayer player,
                                      boolean wasRestored) {
      if (!wasRestored) {
          player.cueVideo(VIDEO_ID);
      }
  }
  
      }
  </code></pre>
  
  <p>Manifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="pl.krasiniak.krachapp_beta"
  android:versionCode="2"
  android:versionName="1.1" &gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="19" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;usues-library android:name="com.google.android.youtube.player"/&gt;
      &lt;activity
          android:name="pl.krasiniak.krachapp_beta.MainActivity"
          android:label="@string/app_name"
          android:screenOrientation="portrait" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="pl.krasiniak.krachapp_beta.Schedule"
          android:label="Plan Lekcji"
          android:parentActivityName="pl.krasiniak.krachapp_beta.MainActivity"
          android:screenOrientation="portrait" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="pl.krasiniak.krachapp_beta.MainActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="pl.krasiniak.krachapp_beta.TimeTable"
          android:label="Tablica"
          android:parentActivityName="pl.krasiniak.krachapp_beta.MainActivity"
          android:screenOrientation="portrait" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="pl.krasiniak.krachapp_beta.MainActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="pl.krasiniak.krachapp_beta.AboutApp"
          android:label="O Aplikacji"
          android:parentActivityName="pl.krasiniak.krachapp_beta.MainActivity"
          android:screenOrientation="portrait" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="pl.krasiniak.krachapp_beta.MainActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="pl.krasiniak.krachapp_beta.Changes"
          android:label="@string/title_activity_changes"
          android:parentActivityName="pl.krasiniak.krachapp_beta.MainActivity"
          android:screenOrientation="portrait" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="pl.krasiniak.krachapp_beta.MainActivity" /&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name="pl.krasiniak.krachapp_beta.Studio"
          android:label="@string/title_activity_studio"
          android:parentActivityName="pl.krasiniak.krachapp_beta.MainActivity"
          android:screenOrientation="portrait"&gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="pl.krasiniak.krachapp_beta.MainActivity" /&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>I've read many topics on stack becouse this is common error but none solution worked for me. Greetings!</p>
  
  <p>EDIT: Here is my activity_studio.xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:layout_gravity="center"
  android:gravity="center_horizontal"&gt;
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Hello YouTube API"
      android:layout_margin="12dip"/&gt;
  &lt;com.google.android.youtube.player.YouTubePlayerView
      android:id="@+id/youtube_view"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="12dip"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>And it says it's error becouse:</p>
  
  <pre><code>java.lang.IllegalStateException: A YouTubePlayerView can only be created with an Activity which extends YouTubeBaseActivity as its context.
  </code></pre>
  
  <p>But it still isn't clear for me</p>