ittianyu / BottomNavigationViewEx

An android lib for enhancing BottomNavigationView. 一个增强BottomNavigationView的安卓库。
MIT License
3.47k stars 558 forks source link

Crush app after update com.google.android.material from 1.3.0 to 1.4.0 #197

Open mobile-sergey opened 3 years ago

mobile-sergey commented 3 years ago

On 'com.google.android.material:material:1.3.0' all working good.

But when I update to 'com.google.android.material:material:1.4.0' I get error in BottomNavigationViewEx:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{club.people.fitness.debug/club.people.fitness.ui_activity.MainActivity}: android.view.InflateException: Binary XML file line #81 in club.people.fitness.debug:layout/activity_main: Binary XML file line #81 in club.people.fitness.debug:layout/activity_main: Error inflating class com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     **Caused by: android.view.InflateException: Binary XML file line #81 in club.people.fitness.debug:layout/activity_main: Binary XML file line #81 in club.people.fitness.debug:layout/activity_main: Error inflating class com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
     Caused by: android.view.InflateException: Binary XML file line #81 in club.people.fitness.debug:layout/activity_main: Error inflating class com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx**
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:852)
        at android.view.LayoutInflater.createView(LayoutInflater.java:774)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.createCustomViewInternal(-ViewPumpLayoutInflater.kt:209)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.access$createCustomViewInternal(-ViewPumpLayoutInflater.kt:19)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$PrivateWrapperFactory2ViewCreator.onCreateView(-ViewPumpLayoutInflater.kt:421)
        at io.github.inflationx.viewpump.internal.-FallbackViewCreationInterceptor.intercept(-FallbackViewCreationInterceptor.kt:14)
        at io.github.inflationx.viewpump.internal.-InterceptorChain.proceed(-InterceptorChain.kt:30)
        at io.github.inflationx.calligraphy3.CalligraphyInterceptor.intercept(CalligraphyInterceptor.java:18)
        at io.github.inflationx.viewpump.internal.-InterceptorChain.proceed(-InterceptorChain.kt:30)
        at io.github.inflationx.viewpump.ViewPump.inflate(ViewPump.kt:36)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater$PrivateWrapperFactory2.onCreateView(-ViewPumpLayoutInflater.kt:399)
        at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:237)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1067)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:995)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.inflate(-ViewPumpLayoutInflater.kt:57)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
        at io.github.inflationx.viewpump.internal.-ViewPumpLayoutInflater.inflate(-ViewPumpLayoutInflater.kt:48)
E/AndroidRuntime:     at club.people.fitness.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:92)
        at club.people.fitness.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:86)
        at club.people.fitness.ui_activity.MainActivity.onCreate(MainActivity.java:35)

Error on this line:

        binding = ActivityMainBinding.inflate(getLayoutInflater());

Layout with error from line #81:

    <com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/white"
        android:visibility="gone"
        app:itemIconTint="@drawable/navigation_color"
        app:itemTextColor="@color/cyan"
        app:labelVisibilityMode="unlabeled"
        app:layout_anchorGravity="bottom"
        app:menu="@menu/footer" />
rafiqlightwala commented 3 years ago

Any update on this?

balkarov commented 3 years ago

+1

SergeyMilevskiy commented 3 years ago

The same for me, maybe it's time to switch to a navigation pattern :|

javadghane commented 3 years ago

Same as me, after updating to 1.4.0 this issue found.

No8blackball commented 3 years ago

+1

amentan commented 3 years ago

+1

mobile-sergey commented 3 years ago

I did not receive a response from the developer, so I decided to replace BottomNavigationViewEx with standard BottomNavigationView. It's easy. May be it will be useful for somebody.

Replace BottomNavigationViewEx to standard

  1. First of all I delete dependency from build.gradle:

    implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.4'
  2. Delete all BottomNavigationViewEx from ProGuard

    -keep public class com.google.android.material.bottomnavigation.BottomNavigationView { *; }
    -keep public class com.google.android.material.bottomnavigation.BottomNavigationMenuView { *; }
    -keep public class com.google.android.material.bottomnavigation.BottomNavigationPresenter { *; }
    -keep public class com.google.android.material.bottomnavigation.BottomNavigationItemView { *; }
  3. Replace in layouts (and delete all specific attributes):

    com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx

    change to:

    com.google.android.material.bottomnavigation.BottomNavigationView
  4. Run project and delete all specific code from modules that get errors: For example: enableShiftingMode(), enableItemShiftingMode(), setTextVisibility(), setIconSizeAt(), setIconMarginTop()

Change all with Badge

  1. Delete dependency from build.gradle:

    implementation 'q.rorbin:badgeview:1.1.0'
  2. Replace all imports Badge to imports BadgeDrawable For example:

    import q.rorbin.badgeview.Badge;
    import q.rorbin.badgeview.QBadgeView;

    replace to:

    import com.google.android.material.badge.BadgeDrawable;
  3. Replace using class Badge into class BadgeDrawable and refactoring all code with Badge and BadgeView For example:

    Badge badge = new QBadgeView(context).bindTarget(context.binding.navigation.getBottomNavigationItemView(position));
    badge.setBadgeNumber(number);
    if (number == 0) {
    badge.hide(true);
    }

    replace to:

    BadgeDrawable badge = context.binding.navigation.getOrCreateBadge(R.id.navigation_tab1);
    badge.setNumber(number);
    badge.setVisible(number > 0);

Finish

  1. Now I update material library. And tune standard BottomNavigationView for my tasks with stackoverflow and Google documentation :)
haodongLing commented 3 years ago

我也遇到了类似的问题

java.lang.RuntimeException: Unable to start activity ComponentInfo{io.github.haodongling.ppjokenew/io.github.haodongling.ppjokenew.MainActivity}: android.view.InflateException: Binary XML file line #14 in io.github.haodongling.ppjokenew:layout/activity_main: Binary XML file line #23 in io.github.haodongling.ppjokenew:layout/fragment_main: Binary XML file line #23 in io.github.haodongling.ppjokenew:layout/fragment_main: Error inflating class com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:213)
        at android.app.ActivityThread.main(ActivityThread.java:8178)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

appcomat 和materil 版本如下 const val material = "1.3.0-alpha03" const val appcompat = "1.2.0"

xiemy1214 commented 2 years ago

+1

GabrielOrAnder commented 2 years ago

+1