hbb20 / hbb20/CountryCodePickerProject

Error Inflating CountryCodePicker in new version 2.3.1

Open
#339 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.5k
Forks
509
PR merge metrics
No merged PRs in 30d

Description

I use android X in my app. So i take the latest version of CountryCodePicker to use.
When i launch the fragment where is the widget, my app crash with this error : android.view.InflateException: Binary XML file line #44: Binary XML file line #44: Error inflating class com.hbb20.CountryCodePicker

Here is the stack

```
W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setVisibility(int)' on a null object reference
W/System.err: at com.hbb20.CountryCodePicker.refreshArrowViewVisibility(CountryCodePicker.java:478)
W/System.err: at com.hbb20.CountryCodePicker.applyCustomProperty(CountryCodePicker.java:309)
at com.hbb20.CountryCodePicker.init(CountryCodePicker.java:220)
at com.hbb20.CountryCodePicker.(CountryCodePicker.java:156)
at java.lang.reflect.Constructor.newInstance0(Native Method)
W/System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
W/System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
W/System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
W/System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at io.kamix.kamix.ui.login.KamixLoginMobileFragment.onCreateView(KamixLoginMobileFragment.java:51)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
W/System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
W/System.err: at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
W/System.err: at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
W/System.err: at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
W/System.err: 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:22731)
W/System.err: at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
W/System.err: at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:22731)
W/System.err: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
W/System.err: at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
W/System.err: at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
W/System.err: at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22731)
W/System.err: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:726)
W/System.err: at android.view.View.measure(View.java:22731)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2530)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1557)
W/System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1825)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1445)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7013)
W/System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:921)
at android.view.Choreographer.doCallbacks(Choreographer.java:729)
at android.view.Choreographer.doFrame(Choreographer.java:664)
W/System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:907)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err: at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.kamix.kamix, PID: 2863
android.view.InflateException: Binary XML file line #44: Binary XML file line #44: Error inflating class com.hbb20.CountryCodePicker
Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class com.hbb20.CountryCodePicker
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at io.kamix.kamix.ui.login.KamixLoginMobileFragment.onCreateView(KamixLoginMobileFragment.java:51)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2439)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
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:22731)
at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22731)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6789)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
E/AndroidRuntime: at com.android.internal.policy.DecorView.onMeasure(DecorView.java:726)
at android.view.View.measure(View.java:22731)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2530)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1557)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1825)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1445)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:921)
at android.view.Choreographer.doCallbacks(Choreographer.java:729)
at android.view.Choreographer.doFrame(Choreographer.java:664)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:907)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RelativeLayout.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
at com.hbb20.CountryCodePicker.init(CountryCodePicker.java:222)
at com.hbb20.CountryCodePicker.(CountryCodePicker.java:156)
... 67 more
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in CountryCodePicker.java at refreshArrowViewVisibility (line 478), then trace applyCustomProperty and init from the reported stack. Reproduce inflating the CountryCodePicker in the fragment and verify that the widget no longer crashes during inflation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.