title: Android Library Declare-Styleable Runtime Error
body: <p>I have a library with some widgets in maven central. When I add that library as a dependency (from maven central) to a project using gradle, I get:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: com.my.pacakge.R$styleable
  </code></pre>
  
  <p>If I manually download the .aar and include that in the project, everything works fine. I tried using Android Studio's code completion to see if the library's <code>R</code> was included. When I use the maven dependency, typing <code>com.my.pacakge.R</code> returns no results, but when I use a local .aar it returns the <code>R</code> for the library.</p>
  
  <p>Here's the library code:</p>
  
  <pre><code>// widget constructor
  public ForegroundImageView(Context context, AttributeSet attrs) {
      super(context, attrs);
  
      TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundImageView);
      Drawable foreground = a.getDrawable(R.styleable.ForegroundImageView_android_foreground);
      if (foreground != null) {
          setForeground(foreground);
      }
      a.recycle();
  }
  
  // attrs.xml
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;declare-styleable name="ForegroundImageView"&gt;
          &lt;attr name="android:foreground"/&gt;
      &lt;/declare-styleable&gt;
  &lt;/resources&gt;
  </code></pre>