3

We have the following crash a LOT... it only comes from Huawei P30 devices running Android 10

android.view.InflateException: Binary XML file line #67 in com.app.test:layout/view_flight_leg: Binary XML file line #67 in com.app.test:layout/view_flight_leg: Error inflating class com.app.test.views.FlightProgressBar
  at java.lang.reflect.Constructor.newInstance0(Constructor.java)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
  at android.view.LayoutInflater.createView(LayoutInflater.java:864)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:1136)
  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
  at com.app.test.views.FlightLegView.<init>(FlightLegView.java:54)
  at com.app.test.views.FlightLegView.<init>(FlightLegView.java:69)
  at com.app.test.views.FlightLegView.<init>(FlightLegView.java:73)
  at com.app.test.PlaneDetailPageFragment.setupFlightProgress(PlaneDetailPageFragment.java:104)
  at com.app.test.PlaneDetailOverviewFragment.setupPlaneUI(PlaneDetailOverviewFragment.java:270)
  at com.app.test.PlaneDetailOverviewFragment.onViewCreated(PlaneDetailOverviewFragment.java:152)
  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:892)
  at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
  at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
  at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
  at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
  at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
  at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
  at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:1696)
  at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:299)
  at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:235)
  at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
  at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
  at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at android.view.View.measure(View.java:24729)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:1002)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:728)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at android.view.View.measure(View.java:24729)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:1002)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:728)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at androidx.appcompat.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:403)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1562)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:849)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:728)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6903)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at com.android.internal.policy.DecorView.onMeasure(DecorView.java:896)
  at android.view.View.measure(View.java:24729)
  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3206)
  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1969)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2290)
  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1852)
  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8084)
  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1057)
  at android.view.Choreographer.doCallbacks(Choreographer.java:875)
  at android.view.Choreographer.doFrame(Choreographer.java:776)
  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1042)
  at android.os.Handler.handleCallback(Handler.java:888)
  at android.os.Handler.dispatchMessage(Handler.java:100)
  at android.os.Looper.loop(Looper.java:213)
  at android.app.ActivityThread.main(ActivityThread.java:8147)
  at java.lang.reflect.Method.invoke(Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
  Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void java.util.List.clear()' on a null object reference
    at android.widget.AbsSeekBar.updateGestureExclusionRects(AbsSeekBar.java:779)
    at android.widget.AbsSeekBar.setThumbPos(AbsSeekBar.java:763)
    at android.widget.AbsSeekBar.onVisualProgressChanged(AbsSeekBar.java:657)
    at android.widget.ProgressBar.setVisualProgress(ProgressBar.java:1653)
    at android.widget.ProgressBar.doRefreshProgress(ProgressBar.java:1605)
    at android.widget.ProgressBar.refreshProgress(ProgressBar.java:1670)
    at android.widget.ProgressBar.setProgressInternal(ProgressBar.java:1742)
    at android.widget.ProgressBar.setProgress(ProgressBar.java:1706)
    at com.app.test.views.FlightProgressBar.setProgress(FlightProgressBar.java:98)
    at android.widget.ProgressBar.<init>(ProgressBar.java:336)
    at android.widget.AbsSeekBar.<init>(AbsSeekBar.java:120)
    at android.widget.SeekBar.<init>(SeekBar.java:89)
    at android.widget.SeekBar.<init>(SeekBar.java:85)
    at androidx.appcompat.widget.AppCompatSeekBar.<init>(AppCompatSeekBar.java:47)
    at androidx.appcompat.widget.AppCompatSeekBar.<init>(AppCompatSeekBar.java:43)
    at com.app.test.views.FlightProgressBar.<init>(FlightProgressBar.java:36)

I cannot work out why this is the case, all other Android 10 (and lower) devices are ok.

Update with setProgress()

@Override
    public synchronized void setProgress(int progress) {
        if (!mShowThumb) {
            setThumb(getResources().getDrawable(R.drawable.scrubber_flight_invisible));
        } else {
            setThumb(mThumb);
        }   
        super.setProgress(progress);
    }
Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
  • what is your min and max sdk in app.gradle – Edgar Jan 25 '20 at 17:41
  • What is your `FlightProgressBar` implementation? In particular, are you doing anything unusual in your overridden `setProgress()` function? – CommonsWare Jan 25 '20 at 17:42
  • My min SDK is 16 with the target and compile set to 29 – Lee Armstrong Jan 25 '20 at 17:48
  • @commonsware See edit above, line 98 is the super.setProgress(progress); line – Lee Armstrong Jan 25 '20 at 17:49
  • 1
    OK, that seems fine. So, here are some brainstormed ideas for how to proceed: Do you have any ordinary `ProgressBar` widgets in the app, and are they working OK? Do you have a Huawei device that exhibits the problem, and if so, if you switch to a regular `ProgressBar`, does it work OK? Are you up to date on `appcompat`? Have you tried an Android 10 device with gesture navigation enabled, since this seems to be tied to `updateGestureExclusionRects()`? – CommonsWare Jan 25 '20 at 17:53
  • Good idea, I don't have a Huawei device here but wanted to avoid getting one! I will try a Pixel device I have with gesture navigation enabled. Great idea! No regular ProgressBar's in the app but I might see if we can switch to one – Lee Armstrong Jan 25 '20 at 17:59
  • So I don't think the issue happens when I use a regular `ProgressBar` One clue from users is that it's when they use "EMUI 10.0" – Lee Armstrong Jan 27 '20 at 08:07
  • 1
    @CommonsWare I bought a Huawei P30, when it was on EMUI 9.0 it didn't crash and I can at least replicate it now. Using a normal ProgressBar does not cause the crash. Who should I report the bug with `AppCompatSeekBar` to? – Lee Armstrong Jan 29 '20 at 17:44
  • 1
    If you can create a sample project that demonstrates the issue, go to https://issuetracker.google.com/issues and file an issue in the "Android Public Tracker > App Development > Jetpack (androidx) > AppCompat" component. The key is the sample project, though, as that significantly increases the chances that your issue will be investigated. – CommonsWare Jan 29 '20 at 17:53
  • Thanks, I have just found that I can get it to not crash when I comment out the setThumb calls (it obviously doesn't look right though) ` @Override public synchronized void setProgress(int progress) { // if (!mShowThumb) { // setThumb(getResources().getDrawable(R.drawable.scrubber_flight_invisible)); // } else { // setThumb(mThumb); // } super.setProgress(progress); } ` – Lee Armstrong Jan 29 '20 at 18:00

1 Answers1

0

when encountered this exception android.view.InflateException , after many times of consulting, we found the reason, so we took a note to record it

The main reason is that I have rewritten a view, but did not write its constructors. So, if I know the reason, the solution is very simple, just rewrite all constructors. rewrite ViewFlipper And rewrite super(context); and super(context, attrs);

Mary
  • 11
  • 1