Roboelectric version 3.0 not able to build using product flavours

53 views
Skip to first unread message

vilas talewale

unread,
Oct 29, 2015, 3:01:50 AM10/29/15
to Robolectric
Hi Team,

My Project structure 

src->main
          com.example.MainActivity
        test
          com.example.MainActivity.MainActivityTest

build.gradle
         testCompile 'junit:junit:4.12'
testCompile('org.robolectric:robolectric:3.0')


vilas talewale

unread,
Oct 29, 2015, 3:15:53 AM10/29/15
to Robolectric
Hi Team,

My Project structure 

src->main
          com.example.MainActivity
          res-flavor1
             flavor1
               values
                   strings.xml
          res-flavor2
             flavor2
                 values 
                  strings.xml  
        test
          com.example.MainActivity.MainActivityTest

build.gradle
            productFlavors {
   
             flavor1{
                  com.example.bash
            }
            flavor1{
                  com.example.dash
            }
}
     
            dependencies{
          testCompile 'junit:junit:4.12'
     testCompile 'org.robolectric:robolectric:3.0'
       testCompile 'org.robolectric:robolectric-annotations:3.0'
       testCompile 'org.robolectric:shadows-core:3.0' 
           }

MainActivityTest file


@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class,sdk=21, packageName = "com.example")
public class MainActivityTest{

@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}

}

As it compiled the Test successfully
But at runtime giving me the error as 

java.lang.RuntimeException: build\intermediates\res\flavor1debug\values is not a directory
at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:27)
at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:32)
at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:19)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:52)
at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:51)
at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
at org.robolectric.manifest.MetaData.init(MetaData.java:53)
at org.robolectric.manifest.AndroidManifest.initMetaData(AndroidManifest.java:343)
at org.robolectric.res.builder.DefaultPackageManager.addManifest(DefaultPackageManager.java:417)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:74)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:185)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:149)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

java.lang.RuntimeException: java.lang.RuntimeException: build\intermediates\res\flavor1debug\values is not a directory
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:238)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:185)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:149)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.RuntimeException: build\intermediates\res\staging\debug\values is not a directory
at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:27)
at org.robolectric.res.PackageResourceLoader.loadEverything(PackageResourceLoader.java:32)
at org.robolectric.res.PackageResourceLoader.doInitialize(PackageResourceLoader.java:19)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.OverlayResourceLoader.doInitialize(OverlayResourceLoader.java:22)
at org.robolectric.res.XResourceLoader.initialize(XResourceLoader.java:29)
at org.robolectric.res.XResourceLoader.getValue(XResourceLoader.java:52)
at org.robolectric.res.OverlayResourceLoader.getValue(OverlayResourceLoader.java:51)
at org.robolectric.res.RoutingResourceLoader.getValue(RoutingResourceLoader.java:31)
at org.robolectric.manifest.MetaData.init(MetaData.java:53)
at org.robolectric.manifest.AndroidManifest.initMetaData(AndroidManifest.java:343)
at org.robolectric.res.builder.DefaultPackageManager.addManifest(DefaultPackageManager.java:417)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:74)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234)
... 18 more


Process finished with exit code -1


vilas talewale

unread,
Oct 29, 2015, 8:45:41 AM10/29/15
to Robolectric
Not able to find a directory build\intermediates\assets\staging\debug\values
Able to find a directory build\intermediates\assets\staging\debug
in android studio
Reply all
Reply to author
Forward
0 new messages