BottomBar icon indicating copy to clipboard operation
BottomBar copied to clipboard

Error inflating class com.roughike.bottombar.BottomBar

Open arodrigueze0215 opened this issue 7 years ago • 12 comments

I am getting an error that maybe is popular as a issues here, but I can't to fix it Help please. 01-23 14:21:46.802 16323-16323/app.platzigram E/AndroidRuntime: FATAL EXCEPTION: main Process: app.platzigram, PID: 16323 java.lang.RuntimeException: Unable to start activity ComponentInfo{app.platzigram/app.platzigram.views.ContainerActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #7: Error inflating class com.roughike.bottombar.BottomBar at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #7: Error inflating class com.roughike.bottombar.BottomBar Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.roughike.bottombar.BottomBar Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:994) at android.view.LayoutInflater.rInflate(LayoutInflater.java:854) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at android.view.LayoutInflater.inflate(LayoutInflater.java:377) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at app.platzigram.views.ContainerActivity.onCreate(ContainerActivity.java:21) at android.app.Activity.performCreate(Activity.java:6662) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.ArithmeticException: divide by zero at com.roughike.bottombar.BottomBar.resizeTabsToCorrectSizes(BottomBar.java:322) at com.roughike.bottombar.BottomBar.updateItems(BottomBar.java:310) at com.roughike.bottombar.BottomBar.setItems(BottomBar.java:246) at com.roughike.bottombar.BottomBar.setItems(BottomBar.java:229) at com.roughike.bottombar.BottomBar.init(BottomBar.java:122) at com.roughike.bottombar.BottomBar.<init>(BottomBar.java:111) at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:430)  at android.view.LayoutInflater.createView(LayoutInflater.java:645)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:994)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)  at android.view.LayoutInflater.inflate(LayoutInflater.java:518)  at android.view.LayoutInflater.inflate(LayoutInflater.java:426)  at android.view.LayoutInflater.inflate(LayoutInflater.java:377)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)  at app.platzigram.views.ContainerActivity.onCreate(ContainerActivity.java:21)  at android.app.Activity.performCreate(Activity.java:6662)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

That's crashing on my BottomBar.xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottombar"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        app:bb_activeTabColor="@android:color/white"
        app:bb_inActiveTabColor="@android:color/white"
        app:bb_tabXmlResource="@xml/bottombartaps"/>
</RelativeLayout>

I Built and cleaned the project before, but doesn't working

arodrigueze0215 avatar Jan 23 '17 19:01 arodrigueze0215

Post your entire .xml, please.

leonardo2204 avatar Jan 23 '17 20:01 leonardo2204

this is my full xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottombar"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        app:bb_activeTabColor="@android:color/white"
        app:bb_inActiveTabColor="@android:color/white"
        app:bb_tabXmlResource="@xml/bottombartaps"/>
</RelativeLayout>

arodrigueze0215 avatar Jan 23 '17 20:01 arodrigueze0215

The code seems ok.. Which OS version are you using ?

leonardo2204 avatar Jan 23 '17 20:01 leonardo2204

The min Android Sdk version is 16. And my desktop OS version is Microsoft Windows 10 Pro

arodrigueze0215 avatar Jan 23 '17 20:01 arodrigueze0215

Exact same error here... Building on latest android studio on win10, minSDK 18, max 25

lamba92 avatar Feb 23 '17 21:02 lamba92

@Lamba92 @Are0215

This is the cause of the exception:

java.lang.ArithmeticException: divide by zero
        at com.roughike.bottombar.BottomBar.resizeTabsToCorrectSizes(BottomBar.java:322)

By reading BottomBar.java#L246 and BottomBar.java#L268, I found that if no tab item in the tabs.xml which specified by app:bb_tabXmlResource, this exception will happen.

ChaosLeung avatar Mar 03 '17 01:03 ChaosLeung

Ok... I will test that..

arodrigueze0215 avatar Mar 03 '17 14:03 arodrigueze0215

@Are0215 the issue was caused by a mistake of mine in the tab xml: i was not declaring properly all the tabs and consequently the bottom bar was not viewing any tab at all and trying to render the preview anyway; i suggest to handle the exception with just a warning to review the xml file. I am sorry i did not got it earlier and warned you. By the way the problem could have been avoided by Android Studio using the standard xml menu offered by the SDK instead of a custom one. May i ask why @roughike choose a custom one?

lamba92 avatar Mar 06 '17 13:03 lamba92

The reason for that is simply that a lot of the custom attributes for tabs aren't supported by the standard menu resources. Only title and icon.

Are you guys having this issue? If so, which versions?

roughike avatar Mar 23 '17 20:03 roughike

@roughike do you want to have a look at it, or do i take a look at it tonight?

yombunker avatar Mar 23 '17 20:03 yombunker

any news guys?!!

quensh93 avatar Apr 17 '17 12:04 quensh93

@Are0215 can you post the bottombartaps xml file?

FR0ST1N avatar Aug 06 '17 08:08 FR0ST1N