title: findViewById returns null after setting XML value instead of hard coded value in one of XML files
body: <p>I'm new to Android programming and I have a very strange problem. I have a few .xml files containing layer-lists with shape inside (I use them for buttons' background) and every file is very similar to this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;item
              android:bottom="-7dp"
              android:left="-7dp"
              android:right="1dp"
              android:top="-7dp"&gt;
          &lt;shape android:shape="rectangle" &gt;
              &lt;stroke
                      android:width="2dp"
                      android:color="#FFFF0000" /&gt;
  
              &lt;solid android:color="#00FFFFFF" /&gt;
  
              &lt;padding android:left="0dp"
                       android:right="0dp"
                       android:top="0dp"
                       android:bottom="0dp" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
  
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>Now when I replace value of    <code>android:width</code>    in stroke with value defined in separate <code>dimens.xml</code> file (in res/values directory) like that: <code>android:width="@dimen/grid_thickness"</code>, save it, compile (without errors) and run on my device whole applications crashes. I found out that it crashes because suddenly <code>findViewById</code> method (called after <code>setContentView</code>) in onCreate method of my activity returns null.</p>
  
  <p>I spent hours on this problem and I am sure that changing "2dp" with "@dimen/grid_thickness" is a reason of returning null from findViewById method. <strong>Apparently changing it back is not enough. I have to delete whole <code>dimens.xml</code> file to make my application work again.</strong> This is very strange.</p>
  
  <p>Here is my haunted <code>dimens.xml</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;dimen name="grid_thickness"&gt;2dp&lt;/dimen&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>And here is a code of onCreate method (NullPointerException is thrown at the last line):</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      header = (TextView) findViewById(R.id.headerText);
      header.setText("sometext");
  }
  </code></pre>
  
  <p>I also tried reaching other views with same result. Everything works without that dimens.xml, so a problem is not in activity code in my opinion.</p>
  
  <p>And here is a fragment of my main.xml file where I reach that layer-list:</p>
  
  <pre><code>&lt;package.path.ClassExtendingButton
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="   "
          android:background="@drawable/border_ul_corner"
          android:id="@+id/field0" android:layout_row="0" android:layout_column="0"
          android:textSize="30dp" android:layout_gravity="fill_horizontal"
          android:paddingTop="30dp" android:onClick="makeMove" android:paddingLeft="30dp"
          android:paddingRight="30dp" android:paddingBottom="30dp"/&gt;
  </code></pre>
  
  <p>I reach it in <code>android-background</code> attribute.</p>
  
  <p>Stacktrace from logcat:</p>
  
  <pre><code>03-20 18:04:53.959    8903-8903/pum.l2.zad1 E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: pum.l2.zad1, PID: 8903
      java.lang.RuntimeException: Unable to start activity ComponentInfo{pum.l2.zad1/pum.l2.zad1.MyActivity}: java.lang.NullPointerException
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
              at android.app.ActivityThread.access$800(ActivityThread.java:139)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5103)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
              at pum.l2.zad1.MyActivity.onCreate(MyActivity.java:66)
              at android.app.Activity.performCreate(Activity.java:5275)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2166)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2252)
              at android.app.ActivityThread.access$800(ActivityThread.java:139)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5103)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>As I said before: NullPointerException is being thrown after trying to reach method of something returned from findViewById (it can be anything, I tried many different views from my layout).</p>
  
  <p>I am using IntelliJ Idea 14.0.3 and 19 Android API version. I heard that there are some bugs related to Android in this version of my IDE. Maybe this is a reason?</p>