0

I am following [this tutorial][1], it has 2 parts. I followed part 1 and ran the app, it worked perfectly. Then I followed part 2 and I keep getting this RuntimeException

09-03 18:32:29.339: E/AndroidRuntime(21044): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tvgenius/com.tvgenius.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
09-03 18:32:29.339: E/AndroidRuntime(21044):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
09-03 18:32:29.339: E/AndroidRuntime(21044):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)

I followed the tutorial exactly. I don't know what I'm missing...

Solution: minSdkVersion for Fragments required is 12, mine was 11.

KickAss
  • 4,210
  • 8
  • 33
  • 41

1 Answers1

1

to use fragments you need minimum sdk version to be 12 or you have to download a support library.

Just right click on your project->android tools -> add support library...

Instead of:

import android.app.Fragment;

you have to use:

import android.support.v4.app.Fragment;
Dyna
  • 2,304
  • 1
  • 14
  • 25
  • The MainActivity is added to the Manifest. Which other one? – KickAss Sep 03 '13 at 17:42
  • That's it :) the `minSdkVersion` was the problem. Changed to 12 and it worked :) – KickAss Sep 03 '13 at 17:51
  • better use support library so you can lower your minSdk back. – Marcin Orlowski Sep 03 '13 at 17:57
  • I went to Project > here there is no Android Tools. I went to Window > Android SDK Manager > I installed Extras > "Android Support Library". How do I add it to my project? – KickAss Sep 03 '13 at 18:04
  • After the click you have to accept the License and then it is done automatically, now you have to change your imports. Instead of: `import android.app.Fragment;` you have to use: `import android.support.v4.app.Fragment;` Also if I gave you the solution to your problem you should accept my answer. – Dyna Sep 04 '13 at 10:57