title: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
body: <p>I was looking for answer for this question (there are a lot of problems coused with this error) but none of them fits me. So I want to call two fragments. If I call only YouTube fragment everything works. On other activitis (with only AdsFragment) everything works fine also.</p>
  
  <p>Here is:</p>
  
  <p>studio.java</p>
  
  <pre><code>public class Studio extends YouTubeFailureRecoveryActivity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_studio);
  
          YouTubePlayerFragment youTubePlayerFragment =
                  (YouTubePlayerFragment) getFragmentManager().findFragmentById(R.id.youtube_fragment);
          youTubePlayerFragment.initialize("myapikey", this);
      }
  
  
      @Override
      public void onStart() {
          super.onStart();
          EasyTracker.getInstance(this).activityStart(this);  // Add this method.
      }
  
  
  
          @Override
          public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
                                              boolean wasRestored) {
              if (!wasRestored) {
                  player.cueVideo("film");
              }
          }
  
          @Override
          protected YouTubePlayer.Provider getYouTubePlayerProvider() {
              return (YouTubePlayerFragment) getFragmentManager().findFragmentById(R.id.youtube_fragment);
          }
  
  
      public void showPlaylist(View view){
  
          Intent intent = YouTubeIntents.createUserIntent(this, "User");
          startActivity(intent);
  
  }
  
  
      @Override
      public void onStop() {
          super.onStop();
          // The rest of your onStop() code.
          EasyTracker.getInstance(this).activityStop(this);  // Add this method.
      }
  }
  </code></pre>
  
  <p>Here is activity_studio.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#cccccc"
      tools:context="pl.krasiniak.krachapp_beta.Studio"
      tools:ignore="MergeRootFrame"&gt;
  
      &lt;fragment
          android:id="@+id/youtube_fragment"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          class = "com.google.android.youtube.player.YouTubePlayerFragment" /&gt;
  
  
      &lt;fragment
          android:gravity="center"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:id="@+id/fragmentAds"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          class="pl.krasiniak.krachapp_beta.AdsFragment"
          android:layout_gravity="center_horizontal|bottom" /&gt;
  
  
      &lt;ImageView
      android:layout_margin="15dp"
      android:src="@drawable/logo_studio"
      android:layout_width="150dp"
      android:layout_height="150dp"
      android:layout_below="@+id/youtube_fragment"
      android:onClick="showPlaylist"
      android:id="@+id/imageView" /&gt;
  
  
      &lt;TextView
      android:scaleType="fitXY"
      android:layout_marginRight="15dp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/StudioKrasiniakText"
      android:layout_alignTop="@+id/imageView"
      android:layout_toRightOf="@+id/imageView" /&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and logcat</p>
  
  <pre><code>01-24 22:00:38.394  14282-14282/pl.krasiniak.krachapp_beta E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.RuntimeException: Unable to start activity ComponentInfo{pl.krasiniak.krachapp_beta/pl.krasiniak.krachapp_beta.Studio}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
              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: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
              at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
              at android.app.Activity.setContentView(Activity.java:1835)
              at pl.krasiniak.krachapp_beta.Studio.onCreate(Studio.java:44)
              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)
       Caused by: java.lang.ClassCastException: pl.krasiniak.krachapp_beta.AdsFragment cannot be cast to android.app.Fragment
              at android.app.Fragment.instantiate(Fragment.java:574)
              at android.app.Fragment.instantiate(Fragment.java:549)
              at android.app.Activity.onCreateView(Activity.java:4235)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
              at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
              at android.app.Activity.setContentView(Activity.java:1835)
              at pl.krasiniak.krachapp_beta.Studio.onCreate(Studio.java:44)
              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>AdsFragment.java</p>
  
  <pre><code>public class AdsFragment extends Fragment implements AdListener {
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) {
  
          View rootView = inflater.inflate(R.layout.fragment_ads, container, false);
  
          assert rootView != null;
          RelativeLayout layout = (RelativeLayout) rootView.findViewById(R.id.fragment_adsLayout);
  
          AdManager mManager = new AdManager(getActivity(), "url", "code", true);
          mManager.setListener(this);
  
          AdView mAdView = new AdView(getActivity(), "url",
                  "code", true, true);
          mAdView.setAdListener(this);
          layout.addView(mAdView);
  
          return rootView;
  
      }
  
      @Override
      public void adClicked() {
  
      }
  
      @Override
      public void adClosed(Ad ad, boolean b) {
  
      }
  
      @Override
      public void adLoadSucceeded(Ad ad) {
  
      }
  
      @Override
      public void adShown(Ad ad, boolean b) {
  
      }
  
      @Override
      public void noAdFound() {
  
      }
  }
  </code></pre>