Butterknife: java.lang.IllegalStateException: at butterknife.internal.Utils.findRequiredView (Utils.java:92)

Created on 8 Feb 2018  ·  5Comments  ·  Source: JakeWharton/butterknife

I have an app using butterknife 8.8.1. A large amount of errors are showing up on my Play Console with the trace:
Caused by: java.lang.IllegalStateException: at butterknife.internal.Utils.findRequiredView (Utils.java:92) at butterknife.internal.Utils.findRequiredViewAsType (Utils.java:104) at com.xxxxxx.ui.activities.ChatActivity_ViewBinding.<init> (ChatActivity_ViewBinding.java:45) at java.lang.reflect.Constructor.newInstance0 (Native Method) at java.lang.reflect.Constructor.newInstance (Constructor.java:430) at butterknife.ButterKnife.createBinding (ButterKnife.java:199) at butterknife.ButterKnife.bind (ButterKnife.java:124) at com.xxxxxx.ui.activities.ChatActivity.onCreate (ChatActivity.java:218) at android.app.Activity.performCreate (Activity.java:6955) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2927)

Every single device listed in my crash reports are Samsung phones/tablets running Android 7.0 or 7.1. I don't any physical device like that to test with, and I've been unable to replicate this error on any of the hardware I have.

Looking at that source file, I should be getting some more information about the illegal state exception by the traces that google is providing don't include the Log message. I can infer that the view it was trying to find was null. Do you have any debugging suggestions for this?

Most helpful comment

I apologize I never posted my fix here...

I had a landscape and portrait layout file. I was disregarding the portrait file and always loading landscape mode, however a few versions of android decided to load the portrait first and THEN load the landscape, and I had one typo with the wrong ID in the portrait layout. Bugsnag worked really well to help me find this (Thanks for the tip Jake Wharton).

I hope that helps you solve your issue.

All 5 comments

I don't really have any tips. The original exception for which that one is the cause has the information required. If you use a third-party crash reporting tool you will receive the entire trace.

Thanks, Jake. So I'm fairly new to Android and I see there's a ton of options available for third party crash reporting. If you have a recommendation I'd love to hear it.

Bugsnag is my favorite: bugsnag.com

Google probably pushes Crashlytics which is part of Fabric which is
semi-first-party.

On Fri, Feb 9, 2018 at 12:58 PM CRoed notifications@github.com wrote:

Thanks, Jake. So I'm fairly new to Android and I see there's a ton of
options available for third party crash reporting. If you have a
recommendation I'd love to hear it.


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/1196#issuecomment-364509468,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEcZNvl_u7eghmdCwhWg3Rs2-7uRqks5tTIcpgaJpZM4R-5c2
.

`Fatal Exception: java.lang.IllegalStateExceptionRequired view 'approval_feed_swipe_refresh' with ID 2131165231 for field 'approvalFeedSwipeRefresh' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation. Raw Text

  | butterknife.internal.Utils.findRequiredView (Utils.java:92)
  | butterknife.internal.Utils.findRequiredViewAsType (Utils.java:104)
  | com.jdlf.compass.ui.fragments.parent.parentapproval.ParentApprovalFragment_ViewBinding. (ParentApprovalFragment_ViewBinding.java:29)
  | java.lang.reflect.Constructor.newInstance0 (Constructor.java)
  | java.lang.reflect.Constructor.newInstance (Constructor.java:430)
  | butterknife.ButterKnife.createBinding (ButterKnife.java:199)
  | butterknife.ButterKnife.bind (ButterKnife.java:172)
  | com.jdlf.compass.ui.fragments.parent.parentapproval.ParentApprovalFragment.onCreateView (ParentApprovalFragment.java:71)
  | android.support.v4.app.Fragment.performCreateView (Fragment.java:1962)
  | android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1016)
  | android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1197)
  | android.support.v4.app.BackStackRecord.run (BackStackRecord.java:738)
  | android.support.v4.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1562)
  | android.support.v4.app.FragmentManagerImpl.executePendingTransactions (FragmentManager.java:535)
  | android.support.v4.app.FragmentStatePagerAdapter.finishUpdate (FragmentStatePagerAdapter.java:163)
  | android.support.v4.view.ViewPager.populate (ViewPager.java:1106)
  | android.support.v4.view.ViewPager.populate (ViewPager.java:952)
  | android.support.v4.view.ViewPager.onMeasure (ViewPager.java:1474)
  | android.view.View.measure (View.java:21289)
  | android.widget.LinearLayout.measureVertical (LinearLayout.java:911)
  | android.widget.LinearLayout.onMeasure (LinearLayout.java:640)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
  | android.widget.LinearLayout.measureVertical (LinearLayout.java:758)
  | android.widget.LinearLayout.onMeasure (LinearLayout.java:640)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
  | android.support.v7.internal.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:124)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
  | android.widget.LinearLayout.measureVertical (LinearLayout.java:758)
  | android.widget.LinearLayout.onMeasure (LinearLayout.java:640)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
  | android.widget.LinearLayout.measureVertical (LinearLayout.java:758)
  | android.widget.LinearLayout.onMeasure (LinearLayout.java:640)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6443)
  | android.widget.FrameLayout.onMeasure (FrameLayout.java:185)
  | com.android.internal.policy.DecorView.onMeasure (DecorView.java:909)
  | android.view.View.measure (View.java:21289)
  | android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:2642)
  | android.view.ViewRootImpl.measureHierarchy (ViewRootImpl.java:1695)
  | android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:1950)
  | android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1567)
  | android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7282)
  | android.view.Choreographer$CallbackRecord.run (Choreographer.java:930)
  | android.view.Choreographer.doCallbacks (Choreographer.java:705)
  | android.view.Choreographer.doFrame (Choreographer.java:640)
  | android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:916)
  | android.os.Handler.handleCallback (Handler.java:751)
  | android.os.Handler.dispatchMessage (Handler.java:95)
  | android.os.Looper.loop (Looper.java:154)
  | android.app.ActivityThread.main (ActivityThread.java:6823)
  | java.lang.reflect.Method.invoke (Method.java)
  | com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1557)
  | com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1445)
`

I'm getting this issue on my app. I can't just make the view @Nullable either, as it is a required field. i have the ids in my R file, and my compilers are all correct.
This issue only affects android tablets. I have tested and phones work without problem

I apologize I never posted my fix here...

I had a landscape and portrait layout file. I was disregarding the portrait file and always loading landscape mode, however a few versions of android decided to load the portrait first and THEN load the landscape, and I had one typo with the wrong ID in the portrait layout. Bugsnag worked really well to help me find this (Thanks for the tip Jake Wharton).

I hope that helps you solve your issue.

Was this page helpful?
0 / 5 - 0 ratings