Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating class fragment class not found android.view.fragment but I am including the compatability library?

I am seeing a class not found exception for android.view.fragment although I am using the compatibility library. Compiles fine but crashes. Is there another package that I should use when pre 3.0? I already changed all fragment classes to android.support.v4.app.Frament but it still crashes because of what is in the layout. My SDK is 4.03 but device is 2.3.

Here is layout

    <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
    android:id="@+id/frag_series"
    android:layout_width="200dip"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    class="com.authorwjf.hello_fragments.ListFrag" />
<fragment
    android:id="@+id/frag_capt"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.authorwjf.hello_fragments.DetailFrag" />
</LinearLayout>

LogCat:

08-08 14:53:21.644: E/AndroidRuntime(13056): Caused by: android.view.InflateException:     Binary    XML file line #6: Error inflating class fragment
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:200)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.app.Activity.setContentView(Activity.java:1647)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at com.authorwjf.hello_fragments.Main.onCreate(Main.java:11)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-08 14:53:21.644: E/AndroidRuntime(13056):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-08 14:53:21.644: E/AndroidRuntime(13056):    ... 11 more
08-08 14:53:21.644: E/AndroidRuntime(13056): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.authorwjf.hello_fragments-2.apk]
08-08 14:53:21.644: E/AndroidRuntime(13056):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
like image 911
Code Droid Avatar asked Dec 17 '25 22:12

Code Droid


1 Answers

Do the same in your layout XML:

<android.support.v4.app.Fragment />

Also, note the capitalization.

like image 152
telkins Avatar answered Dec 19 '25 15:12

telkins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!