Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BottomNavigator] Error when migrated to version 1.3.0 #2064

Closed
paulocoutinhox opened this issue Feb 12, 2021 · 12 comments
Closed

[BottomNavigator] Error when migrated to version 1.3.0 #2064

paulocoutinhox opened this issue Feb 12, 2021 · 12 comments
Labels

Comments

@paulocoutinhox
Copy link

paulocoutinhox commented Feb 12, 2021

Hi,

When i migrate from version 1.2.1 to version 1.3.0 i get this error:

2021-02-11 21:46:46.447 16352-16352/br.com.ubook.ubookapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: br.com.ubook.ubookapp, PID: 16352
    java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.ViewGroup.getPaddingBottom()' on a null object reference
        at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:108)
        at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:89)
        at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:85)
        at com.google.android.material.bottomnavigation.BottomNavigationMenuView.getNewItem(BottomNavigationMenuView.java:634)
        at com.google.android.material.bottomnavigation.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:563)
        at com.google.android.material.bottomnavigation.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:67)
        at com.google.android.material.bottomnavigation.BottomNavigationView.inflateMenu(BottomNavigationView.java:349)
        at br.com.ubook.ubookapp.ui.fragment.MainFragment.createAll(MainFragment.kt:185)
        at br.com.ubook.ubookapp.ui.fragment.BaseFragment.onCreateView(BaseFragment.kt:127)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2699)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368)
        at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509)
        at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
        at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2181)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2004)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2641)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
        at br.com.ubook.ubookapp.ui.activity.BaseActivity.onStart(BaseActivity.kt:552)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
        at android.app.Activity.performStart(Activity.java:7348)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3138)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1948)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7050)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

The line with error is:

navigationLeft.inflateMenu(R.menu.navigation_left_3)

And the content is:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/tab_home_left"
        android:icon="@drawable/ic_tab_home"
        android:title="@string/title_featured" />

    <item
        android:id="@+id/tab_my_products_left"
        android:icon="@drawable/ic_tab_my_products"
        android:title="@string/title_my_products" />

</menu>

I revert it to 1.2.1 to make it work for now.

@hunterstich
Copy link
Contributor

Hey Paulo,

Are you able to attach a small sample that reproduces this issue?

@paulocoutinhox
Copy link
Author

Hi,

Im publish a project demo here (but i cannot reproduce the error):
https://github.com/paulo-coutinho/bottom-nav-md-demo

This is the line with problem (labelGroup = null):

labelGroup.setTag(R.id.mtrl_view_tag_bottom_padding, labelGroup.getPaddingBottom());

And the problem is in this line (screenshot):
image

Thanks.

@hunterstich
Copy link
Contributor

So that sample repo doesn't reproduce this issue?

What is labelGroup? Is that a view of your own?

@paulocoutinhox
Copy link
Author

Hi,

My sample don't throw the same error.

But i put the line of error ^^.

The labelGroup is from your source code. The screenshot is about your source code when error happen. I see that you make a find in view for the element labelGroup and it is null in my app.

@jae-12
Copy link

jae-12 commented Mar 22, 2021

Hi, I am facing the same problem.

Was there a solution for this?

@paulocoutinhox
Copy link
Author

I didn't found one.

@paulocoutinhox
Copy link
Author

Our friend here found the problem.

We have created a new file "res/layout/design_bottom_navigation_item.xml" to replace the original and add our accessibility text.

But it has 3 years and our file don't have the ID field that is recently added android:id="@+id/labelGroup" causing the crash.

We only need add this ID on BaseLineLayout element and it was fixed.

Thanks.

@drchen
Copy link
Contributor

drchen commented Jul 15, 2021

Thanks for the update. : ) Glad to hear it's been fixed! Closing the issue...

@drchen drchen closed this as completed Jul 15, 2021
@Prakhar-kuls
Copy link

Prakhar-kuls commented Apr 7, 2022

It was being caused because of duplicate files from two different versions, one from main and other from dependency. Solved it by forcing one of the version, in build.gradle, main application already was having.

configurations.all {
        resolutionStrategy { 
            force 'com.google.android.material:material:1.2.1'
        }
    }

@hemalHD
Copy link

hemalHD commented Nov 30, 2022

can someone provide proper solutation because i am also facing same issue?
image

@Prakhar-kuls
Copy link

@hemalHD what is the version you are using for com.google.android.material:material in app' build:gradle and in any of module or dependency?
Can you check in dependency graph if 1.2.1 is being used.

@vivekgiri-m
Copy link

vivekgiri-m commented Apr 15, 2024

This issue is still happening when upgrading from 1.2.1 to 1.3.0

This has been raised on StackOverflow as well

Resolved it by creating a duplicate of design_bottom_navigation_item.xml and put it res/layout, got idea from @paulocoutinhox's comment

Screenshot 2024-04-15 at 9 39 31 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants