title: Resources$NotFoundException fatal exception for custom view after proguard, on specific devices
body: <p>I'm getting the following stacktrace for crashes on few specific devices. Both the devices I faced the crash on are running OSv5.1</p>
  
  <pre><code>Fatal Exception: android.view.InflateException: Binary XML file line #161: Error inflating class com.adroitandroid.stitchastory.ui.AppTextInputLayoutPlus
         at android.view.LayoutInflater.createView(LayoutInflater.java:633)
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
         at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:116)
         at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:88)
         at com.adroitandroid.stitchastory.HomeActivity$StartStoryFragment.onCreateView(HomeActivity.java:415)
         at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
         at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
         at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
         at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
         at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1998)
         at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:709)
         at android.os.Handler.handleCallback(Handler.java:815)
         at android.os.Handler.dispatchMessage(Handler.java:104)
         at android.os.Looper.loop(Looper.java:194)
         at android.app.ActivityThread.main(ActivityThread.java:5763)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  Caused by java.lang.reflect.InvocationTargetException
         at java.lang.reflect.Constructor.newInstance(Constructor.java)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
         at android.view.LayoutInflater.createView(LayoutInflater.java:607)
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
         at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:116)
         at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:88)
         at com.adroitandroid.stitchastory.HomeActivity$StartStoryFragment.onCreateView(HomeActivity.java:415)
         at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
         at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
         at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
         at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
         at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1998)
         at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:709)
         at android.os.Handler.handleCallback(Handler.java:815)
         at android.os.Handler.dispatchMessage(Handler.java:104)
         at android.os.Looper.loop(Looper.java:194)
         at android.app.ActivityThread.main(ActivityThread.java:5763)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7f0f007c
         at android.content.res.Resources.getValue(Resources.java:1463)
         at android.support.v7.content.res.AppCompatResources.isColorInt(AppCompatResources.java:161)
         at android.support.v7.content.res.AppCompatResources.inflateColorStateList(AppCompatResources.java:108)
         at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:74)
         at android.support.v7.widget.TintTypedArray.getColorStateList(TintTypedArray.java:136)
         at android.support.design.widget.TextInputLayout.(TextInputLayout.java:244)
         at android.support.design.widget.TextInputLayout.(TextInputLayout.java:183)
         at com.adroitandroid.stitchastory.ui.TextInputLayoutPlus.(TextInputLayoutPlus.java:19)
         at com.adroitandroid.stitchastory.ui.AppTextInputLayoutPlus.(AppTextInputLayoutPlus.java:16)
         at java.lang.reflect.Constructor.newInstance(Constructor.java)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
         at android.view.LayoutInflater.createView(LayoutInflater.java:607)
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
         at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
         at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
         at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:116)
         at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:88)
         at com.adroitandroid.stitchastory.HomeActivity$StartStoryFragment.onCreateView(HomeActivity.java:415)
         at android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
         at android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
         at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
         at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
         at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1998)
         at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:709)
         at android.os.Handler.handleCallback(Handler.java:815)
         at android.os.Handler.dispatchMessage(Handler.java:104)
         at android.os.Looper.loop(Looper.java:194)
         at android.app.ActivityThread.main(ActivityThread.java:5763)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
  </code></pre>
  
  <p>The resource mentioned is</p>
  
  <pre><code>    public static final int design_tint_password_toggle=0x7f0f007c;
  </code></pre>
  
  <p>in my R.java, basically not a resource I've defined myself. However, it is a custom layout that I'm trying to inflate here. For another such previous crash, I explicitly mentioned the text color in my view in xml to fix it. But this is different in that it is an android resource which it couldn't find. This isn't right on app launch either.</p>
  
  <p>To add, this is a proguarded apk, I have the following in my proguard config file to retain the constants.</p>
  
  <pre><code>-keepclassmembers class **.R$* {
      public static &lt;fields&gt;;
  }
  -keep class **.R$*
  </code></pre>
  
  <p>Also I've tried commenting out</p>
  
  <pre><code>shrinkResources true
  </code></pre>
  
  <p>for the particular build type, but it didn't fix this.</p>
  
  <p>I'm using buildToolsVersion '25.0.1'</p>
  
  <p>Support library version is 25.1.0 and <a href="https://gist.github.com/adroitandroid/adc1289e3ecd14c5bad9e6c12e5f684f" rel="nofollow noreferrer">here is the layout file</a> it's trying to inflate when it crashes. Line 161 is where the view related to the crash is declared. Pasting here for convenience.</p>
  
  <pre><code>&lt;com.adroitandroid.stitchastory.ui.AppTextInputLayoutPlus
      android:id="@+id/contribution_til"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignEnd="@id/done_ib"
      android:layout_alignStart="@id/cancel_ib"
      android:layout_below="@id/done_ib"
      android:layout_centerInParent="true"
      android:paddingTop="16dp"
      app:counterEnabled="true"
      app:counterMaxLength="@integer/maxContributionLength"
      app:errorEnabled="true"
      app:hintEnabled="false"&gt;
  
      &lt;com.adroitandroid.stitchastory.ui.ContentEditTextPlus
          android:id="@+id/contribution_et"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="top"
          android:hint="@string/hint_add_story"
          android:imeOptions="actionDone"
          android:inputType="textAutoComplete|textCapSentences|textShortMessage|textMultiLine" /&gt;
  &lt;/com.adroitandroid.stitchastory.ui.AppTextInputLayoutPlus&gt;
  </code></pre>
  
  <p>Nothing fancy about the AppTextInputLayoutPlus, it just takes a custom typeface in the following manner.</p>
  
  <pre><code>abstract class TextInputLayoutPlus extends TextInputLayout {
      public TextInputLayoutPlus(Context context) {
          super(context);
          init();
      }
  
      public TextInputLayoutPlus(Context context, AttributeSet attrs) {
          super(context, attrs);
          init();
      }
  
      public TextInputLayoutPlus(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          init();
      }
  
      private void init() {
          setTypeface(Typeface.createFromAsset(getContext().getAssets(), getTextFont()));
      }
  
      protected abstract String getTextFont();
  }
  // in its own class file
  public class AppTextInputLayoutPlus extends TextInputLayoutPlus {
      public AppTextInputLayoutPlus(Context context) {
          super(context);
      }
  
      public AppTextInputLayoutPlus(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public AppTextInputLayoutPlus(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
      }
  
      @Override
      protected String getTextFont() {
          return AppTextView.APP_TEXT_FONT;
      }
  }
  </code></pre>
  
  <p>Does anyone know a way to fix this, and why this is coming up?</p>