title: Android Studio java.lang.NoClassDefFoundError: module.B.package.R$string
body: <p>I'm migrating from Eclipse to Android Studio. I decided to test and import one of my applications for the Android Studio. </p>
  
  <p>I've managed to import and configure Gradle, compiled just fine, the problem is, when I run the app, it gives me a NoClassDefFoundError error on the line where I get a string in an XML file. </p>
  
  <p>The architecture of the project is more or less like this: Inside the project, the App which has as a module dependency A, which in turn has a B project as a dependency, which in turn has a dependency on the Maven project SherlockActionBar. </p>
  
  <p><strong>App -> Module A -> Module B -> Sherlock (Maven)</strong> </p>
  
  <p>I did some tests and apparently works do this kind of structure without putting the module B as dependency of App.</p>
  
  <p>The problem is when, inside the module B, I pull a string of one example.xml file. Someone help me please!</p>
  
  <p>The error:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: module.B.package.R$string
  </code></pre>
  
  <p>When I run the application in debug, I can see the R.class and the int value ID of the String.</p>
  
  <p>I've tried everything, rebuild, clean, restart IDE, raining dance, magic, everything!!</p>
  
  <p><strong>GRADLE APP:</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 20
      buildToolsVersion '20.0.0'
  
      defaultConfig {
          applicationId "app.id"
          minSdkVersion 9
          targetSdkVersion 20
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              runProguard false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile project(':moduleA')
  }
  </code></pre>
  
  <p><strong>GRADLE MODULE A:</strong></p>
  
  <pre><code>    apply plugin: 'com.android.library'
  
  android {
      compileSdkVersion 20
      buildToolsVersion '20.0.0'
  
      defaultConfig {
          applicationId "moduleA.id"
          minSdkVersion 9
          targetSdkVersion 20
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              runProguard false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile files('libs/estimote-sdk-preview.jar')
      compile 'com.google.android.gms:play-services:4.+'
      compile project(':moduleB')
  }
  </code></pre>
  
  <p><strong>GRADLE MODULE B:</strong></p>
  
  <pre><code>    apply plugin: 'com.android.library'
  
  android {
      compileSdkVersion 20
      buildToolsVersion '20.0.0'
  
      defaultConfig {
          applicationId "moduleB.id"
          minSdkVersion 9
          targetSdkVersion 20
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              runProguard false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile files('libs/commons-lang3-3.1.jar')
      compile files('libs/kilomobileds.jar')
      compile 'com.android.support:support-v4:20.0.+'
      compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
  }
  </code></pre>