6

My application was working but when I came to start working on it this morning everything is not working. I am getting an error inflating class error which seems to be from an xml file where I get the "Binary XML file line #25" line. As I said this was working fine and now all of a sudden it does not. Below is the exception trace:

01-27 11:20:53.624: E/AndroidRuntime(7831): FATAL EXCEPTION: main
01-27 11:20:53.624: E/AndroidRuntime(7831): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ypmmllc.dailychecklist/com.ypmmllc.dailychecklist.TabbedActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2737)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2753)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.ActivityThread.access$2500(ActivityThread.java:129)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2107)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.os.Looper.loop(Looper.java:143)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.ActivityThread.main(ActivityThread.java:4701)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at java.lang.reflect.Method.invokeNative(Native Method)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at java.lang.reflect.Method.invoke(Method.java:521)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at dalvik.system.NativeStart.main(Native Method)
01-27 11:20:53.624: E/AndroidRuntime(7831): Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.createView(LayoutInflater.java:513)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:677)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:614)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.Activity.setContentView(Activity.java:1647)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:180)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:134)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at com.ypmmllc.dailychecklist.TabbedActivity.onCreate(TabbedActivity.java:30)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2701)
01-27 11:20:53.624: E/AndroidRuntime(7831):     ... 11 more
01-27 11:20:53.624: E/AndroidRuntime(7831): Caused by: java.lang.reflect.InvocationTargetException
01-27 11:20:53.624: E/AndroidRuntime(7831):     at android.support.v7.internal.widget.ActionBarView.<init>(ActionBarView.java:218)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at java.lang.reflect.Constructor.constructNative(Native Method)
01-27 11:20:53.624: E/AndroidRuntime(7831):     at java.lang.reflect.Constructor.newInstance(Constructor.java:446)

Here is the XML file it bombs on in my class at setContentView(R.layout.activity_tabbed), as this is the line where everything bombs out.

activity_tabbed.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".TabbedActivity" >


    <view class="com.ypmmllc.dailychecklist.CustomViewPager"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </view>
</RelativeLayout>

And now the CustomViewPager class that I am referencing within the XML file:

package com.ypmmllc.dailychecklist;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewPager extends ViewPager {

    private boolean enabled;

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.enabled = false;
    }

    public CustomViewPager(Context context)
    {
        super(context);
        this.enabled = false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (this.enabled) {
            return super.onTouchEvent(event);
        }

        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.enabled) {
            return super.onInterceptTouchEvent(event);
        }

        return false;
    }

    public void setPagingEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}
Manuel Allenspach
  • 12,467
  • 14
  • 54
  • 76
user3241191
  • 505
  • 2
  • 5
  • 12
  • Have you tried to use ViewPager directly in your XML. Just for test issues. If it works i would recommend to implement the inheriting class without any changes only the "must-have-methods". Maybe it will lead you to the problem. Greetings. – sascha10000 May 14 '14 at 15:08

3 Answers3

8

Try to clean up the project and rebuild it:

IntelliJ IDEA: Build -> Rebuild project; Eclipse: Project -> Clean

Aleksey
  • 239
  • 2
  • 4
  • All that did was just basically not correctly build the project which left the R.java class not being created which is where all the build errors are popping up now. Those are the only errors in the project, that the R.java class is missing. – user3241191 Jan 27 '14 at 16:49
  • I have sometimes the same problem. The solution I found is like @Aleksey. Just cleaning up everything and rebuilding the whole project. Then it starts to work. – Code Pope Aug 29 '14 at 08:21
4

Try this:

<com.ypmmllc.dailychecklist.CustomViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
Blo
  • 11,903
  • 5
  • 45
  • 99
Imran Betara
  • 649
  • 3
  • 8
2

On behalf of OP


It was a settings.xml file I created while trying to create a SettingsActivity for the project. No errors were showing for the file at all and it was named in all lower case. I just completely deleted the file and everything built correctly. I noticed my LogCat was going crazy as well during this time. It just kept scrolling with new information. The whole thing is bizarre because, well, as I stated there were no errors showing within the file and everything was labeled correctly. Also, this was also after doing a clean build of the entire project which no longer produced the error I initially spoke of but than no longer created my R.java file.