title: Android xml style reference attribute crash
body: <p>In my application we have a view that is displayed instead of ListView to indicate the list view is empty. It is inflated from a following xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
          android:orientation="vertical"&gt;
  
          &lt;ImageView
              android:id="@+id/view_empty_state_icon"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:tint="?colorAccent" /&gt;
  
          &lt;Space
              android:layout_width="match_parent"
              android:layout_height="16dp" /&gt;
  
          &lt;TextView
              android:id="@+id/view_empty_state_message"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:textAllCaps="true"
              android:textColor="?colorAccent"
      android:textSize="@dimen/text_xxlarge" /&gt;
  
          &lt;Space
              android:layout_width="match_parent"
              android:layout_height="24dp" /&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Recently, the application started crashing on inflating this view, producing this monster stack:</p>
  
  <pre><code>    android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class &lt;unknown&gt;
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                      at android.view.View.inflate(View.java:19790)
                                                                      at &lt;application package name&gt;.view.EmptyStateView.init(EmptyStateView.java:58)
                                                                      at &lt;application package name&gt;.view.EmptyStateView.&lt;init&gt;(EmptyStateView.java:33)
                                                                      at &lt;application package name&gt;.adapter.ObservationsAdapter.onCreateViewHolder(ObservationsAdapter.java:187)
                                                                      at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5223)
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4449)
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4359)
                                                                      at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
                                                                      at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
                                                                      at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
                                                                      at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
                                                                      at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
                                                                      at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418)
                                                                      at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1482)
                                                                      at android.support.v7.widget.RecyclerView.scrollBy(RecyclerView.java:1399)
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:242)
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:193)
                                                                      at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
                                                                      at android.os.Handler.handleCallback(Handler.java:739)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                      at android.os.Looper.loop(Looper.java:148)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                   Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class &lt;unknown&gt;
                                                                      at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                                                                      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                                                                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                                                                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                      at android.view.View.inflate(View.java:19790) 
                                                                      at &lt;application package name&gt;.view.EmptyStateView.init(EmptyStateView.java:58) 
                                                                      at &lt;application package name&gt;.view.EmptyStateView.&lt;init&gt;(EmptyStateView.java:33) 
                                                                      at &lt;application package name&gt;.adapter.ObservationsAdapter.onCreateViewHolder(ObservationsAdapter.java:187) 
                                                                      at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5223) 
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4449) 
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4359) 
                                                                      at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
                                                                      at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
                                                                      at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
                                                                      at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
                                                                      at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
                                                                      at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
                                                                      at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1482) 
                                                                      at android.support.v7.widget.RecyclerView.scrollBy(RecyclerView.java:1399) 
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:242) 
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:193) 
                                                                      at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45) 
                                                                      at android.os.Handler.handleCallback(Handler.java:739) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                      at android.os.Looper.loop(Looper.java:148) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                      at java.lang.reflect.Method.invoke(Native Method) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                   Caused by: java.lang.reflect.InvocationTargetException
                                                                      at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                      at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
                                                                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                                                                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                      at android.view.View.inflate(View.java:19790) 
                                                                      at &lt;application package name&gt;.view.EmptyStateView.init(EmptyStateView.java:58) 
                                                                      at &lt;application package name&gt;.view.EmptyStateView.&lt;init&gt;(EmptyStateView.java:33) 
                                                                      at &lt;application package name&gt;.adapter.ObservationsAdapter.onCreateViewHolder(ObservationsAdapter.java:187) 
                                                                      at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5223) 
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4449) 
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4359) 
                                                                      at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
                                                                      at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
                                                                      at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
                                                                      at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
                                                                      at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
                                                                      at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
                                                                      at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1482) 
                                                                      at android.support.v7.widget.RecyclerView.scrollBy(RecyclerView.java:1399) 
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:242) 
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:193) 
                                                                      at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45) 
                                                                      at android.os.Handler.handleCallback(Handler.java:739) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                      at android.os.Looper.loop(Looper.java:148) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                      at java.lang.reflect.Method.invoke(Native Method) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                   Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 5: TypedValue{t=0x2/d=0x7f01011a a=-1}
                                                                      at android.content.res.TypedArray.getColorStateList(TypedArray.java:482)
                                                                      at android.widget.ImageView.&lt;init&gt;(ImageView.java:179)
                                                                      at android.widget.ImageView.&lt;init&gt;(ImageView.java:140)
                                                                      at android.widget.ImageView.&lt;init&gt;(ImageView.java:136)
                                                                      at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                      at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
                                                                      at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
                                                                      at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                                                                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                                                                      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                      at android.view.View.inflate(View.java:19790) 
                                                                      at &lt;application package name&gt;.view.EmptyStateView.init(EmptyStateView.java:58) 
                                                                      at &lt;application package name&gt;.view.EmptyStateView.&lt;init&gt;(EmptyStateView.java:33) 
                                                                      at &lt;application package name&gt;.adapter.ObservationsAdapter.onCreateViewHolder(ObservationsAdapter.java:187) 
                                                                      at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5223) 
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4449) 
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4359) 
                                                                      at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961) 
                                                                      at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370) 
                                                                      at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333) 
                                                                      at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562) 
                                                                      at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900) 
                                                                      at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1418) 
                                                                      at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1482) 
                                                                      at android.support.v7.widget.RecyclerView.scrollBy(RecyclerView.java:1399) 
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:242) 
                                                                      at &lt;application package name&gt;.fragment.observations.AbstractListFragment$5.success(AbstractListFragment.java:193) 
                                                                      at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45) 
                                                                      at android.os.Handler.handleCallback(Handler.java:739) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                      at android.os.Looper.loop(Looper.java:148) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                      at java.lang.reflect.Method.invoke(Native Method) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>
  
  <p>It was apparent that the problem was caused by style reference in "tint" attribute ("?colorAccent") of ImageView and TextView, so we changed this reference to static reference to colors.xml file (now the attribute values are "@color/accent"), but I'm curious <b>what could cause the problem in the first place</b>?</p>