Binary XML file line #5: Error inflating class and appcompat support library update

I've recently encountered a problem with my android app. It was working just fine, when suddenly everything crashed from the beginning. The problem in logcat shows its something wrong with setContentView(R.layout.splashscreen) but everything was fine this morning.

I have also tried reverting to my previous version from git but the problem persisted and I don't know why. I don't know which part of the code should I even post, becuase I don't think this is related to my JAVA code, maybe something in XML? Logcat shown below is an outcome after I upgraded appcompat support library from 22.1.1 to 22.2.0

Output after upgrading appcompat support library to 22.2.0

06-23 15:15:41.882 18349-18349/sconnected.nkmaribor E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: sconnected.nkmaribor, PID: 18349 java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:324) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) at pribozic.sconnected.SplashScreen.onCreate(SplashScreen.java:54) at android.app.Activity.performCreate(Activity.java:5275) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250) at android.app.ActivityThread.access$800(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5105) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) at dalvik.system.NativeStart.main(Native Method)

This is the output from Logcat when using appcompat 22.1.1

java.lang.RuntimeException: Unable to start activity ComponentInfo{sconnected.nkmaribor/pribozic.sconnected.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class pribozic.sconnected.views.SlidingTabLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250) at android.app.ActivityThread.access$800(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5105) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class pribozic.sconnected.views.SlidingTabLayout at android.view.LayoutInflater.createView(LayoutInflater.java:620) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106) at pribozic.sconnected.MainActivity.onCreate(MainActivity.java:65)

If there is any code I can provide you that would help you help me, please let me know. Also, I did not change any code on SlidingTabLayout.class for like a month now and everything was working fine until this afternoon.

I've added some of the Objects and changed some database storings but nothing was related to MainActivity.class where the application started to fail. API calls worked fine before appcompat support update and SplashScreen loaded all the informations but after Splash Screen closed, the MainActivity crashed for no apparent reason.

I look forward to any help, Thanks!

EDIT xml and java code for MainActivity

Here is a code for main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:id="@+id/toolbar_actionbar" layout="@layout/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" /> <android.support.v4.widget.DrawerLayout android:id="@+id/drawer" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar_actionbar"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"/> <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> <fragment android:id="@+id/fragment_drawer" android:name="pribozic.sconnected.fragments.NavigationDrawerFragment" android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent" android:layout_gravity="start" app:layout="@layout/fragment_navigation_drawer" tools:layout="@layout/fragment_navigation_drawer" /> </android.support.v4.widget.DrawerLayout> </RelativeLayout>

This is the code for toolbar.xml:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" style="@style/ToolBarStyle" android:layout_width="match_parent" android:layout_height="@dimen/abc_action_bar_default_height_material" android:background="@color/main_color" > <pribozic.sconnected.views.SlidingTabLayout android:background="@color/main_color" android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v7.widget.Toolbar>

And this is the code for SlidingTabLayout constructor (where it showed some of the errors (line 109 and line 96 are the mTabStrip = new SlidingTabStrip(context); and this(context, attrs, 0);

private final SlidingTabStrip mTabStrip; public SlidingTabLayout(Context context) { this(context, null); } public SlidingTabLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }

-------------Problems Reply------------

Ok, so I figured out what the problem was and quickly came up with the solution. The problem was, my program exceeded the 65k limit with all the libraries so what I had to do, was import multidex support library and extend my Application class to MultiDexApplication.

For anyone experiencing the same issue here is the solution:

public class Application extends MultiDexApplication

and then I've also overriden the method:

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

add the dependency to gradle build:

compile 'com.android.support:multidex:1.0.1'

and if you haven't added Application.class to your manifest previously, make sure you add in the application tag

<application>
...
android:name=".Application" //make sure you replace this with your package and name
...
</application>

Category:java Views:4 Time:2019-01-12

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.222 (s). 11 q(s)