gradle(Android)で単体テスト実行時(robolectric利用)にMissingResourceExceptionが発生するのに対処

```java:AppConfig.java
public class AppConfig {

    public static final ResourceBundle bundle = ResourceBundle.getBundle(AppConfig.class.getSimpleName());

    private static final String mAppId = bundle.getString("AppId");
...
}
```

という風にResourceBundleをアプリケーションで使用している場合、そのままRobolectricの単体テストを

```groovy:build.gradle
apply plugin: 'android'
apply plugin: 'robolectric'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    androidTestCompile('junit:junit:4.+')
    androidTestCompile('org.hamcrest:hamcrest-all:1.+')
    androidTestCompile('org.robolectric:robolectric:2.+')
}

android {
    compileSdkVersion 18
    buildToolsVersion "21.1.2"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        androidTest.setRoot('tests')

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    lintOptions { abortOnError false }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

```

```java:tests/java/com/example/SampleActivityTest.java
package com.example;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(emulateSdk = 18)
public class SampleTest {
    @Before public void setup() { // setup }
    @After public void teardown() { // teardown }
    @Test public void sampleFunctionTest() { // test }
}
```
のように追加すると、

```
java.util.MissingResourceException: Can't find bundle for base name AppConfig, locale ja_JP
```
というエラーが出る。よって、androidTestのresourcesのsrcDirsを指定してやればよい。

```groovy:build.gradle
apply plugin: 'android'
apply plugin: 'robolectric'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    androidTestCompile('junit:junit:4.+')
    androidTestCompile('org.hamcrest:hamcrest-all:1.+')
    androidTestCompile('org.robolectric:robolectric:2.+')
}

android {
    compileSdkVersion 18
    buildToolsVersion "21.1.2"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        androidTest.setRoot('tests')
        androidTest { resources.srcDirs = ['src'] } // <- ここを追加する

        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    lintOptions { abortOnError false }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

```
以上。新しい開発環境に移行すると、色々と躓くことが多くて厄介ですねー＞＜