title: Android Studio library modules cant generate R.java
body: <p>I write a library module that other module can depend on.
  I create a library module and write some code in it.
  This is a Custom View. I create attr.xml like this.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;attr name="top_icon" format="reference" /&gt;
      &lt;attr name="bottom_icon" format="reference" /&gt;
  
      &lt;declare-styleable name="GradientIconView"&gt;
          &lt;attr name="top_icon" /&gt;
          &lt;attr name="bottom_icon" /&gt;
      &lt;/declare-styleable&gt;
  
      &lt;attr name="text" format="string" /&gt;
      &lt;attr name="text_size" format="dimension" /&gt;
      &lt;attr name="top_text_color" format="color" /&gt;
      &lt;attr name="bottom_text_color" format="color" /&gt;
  
      &lt;declare-styleable name="GradientTextView"&gt;
          &lt;attr name="text" /&gt;
          &lt;attr name="text_size" /&gt;
          &lt;attr name="top_text_color" /&gt;
          &lt;attr name="bottom_text_color" /&gt;
      &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>I write some code like this.</p>
  
  <pre><code>TypedArray a = context.obtainStyledAttributes(attrs,
              R.styleable.GradientIconView);
  
      BitmapDrawable drawable;
  
      int n = a.getIndexCount();
      for (int i = 0; i &lt; n; i++) {
  
          int attr = a.getIndex(i);
          switch (attr) {
              case R.styleable.GradientIconView_top_icon:
                  drawable = (BitmapDrawable) a.getDrawable(attr);
                  setTopIconView(drawable);
                  break;
              case R.styleable.GradientIconView_bottom_icon:
                  drawable = (BitmapDrawable) a.getDrawable(attr);
                  setBottomIconView(drawable);
                  break;
  
          }
      }
  </code></pre>
  
  <p>It says cannot resolve symbol 'R', i rebuild the project and make the library module. It doesnt work.
  Here is the project structure.
  <a href="https://i.stack.imgur.com/hmuR1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hmuR1.png" alt="Structure about project"></a></p>