0

After mulitple problems in order to use robolectric with android studio, i get an error to create an activity.

So i use the following code

@Before
public void setUp() throws Exception {
    mapActivity = Robolectric.buildActivity(MapActivity_.class).create().visible().get();
}

I've decided to build annotated activity but i fall on this problem (same problem if i build "normal" activity)

WARNING: No manifest file found at /path/to/AndroidManifest.xml.Falling back to the Android OS resources only.
To remove this warning, annotate your test class with @Config(manifest=Config.NONE).
WARNING: no system properties value for ro.build.date.utc

org.fest.reflect.exception.ReflectionError: Unable to create a new object from the enclosed constructor
    at org.fest.reflect.constructor.Invoker.newInstance(Invoker.java:82)
    at org.robolectric.util.ActivityController.<init>(ActivityController.java:41)
    at org.robolectric.Robolectric.buildActivity(Robolectric.java:1376)
    at com.ecab.MapActivityTest.setUp(MapActivityTest.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    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:177)
    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:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    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:134)
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 30
Exception Details:
  Location:
    com/google/android/gms/location/LocationRequest.setExpirationTime(J)Lcom/google/android/gms/location/LocationRequest; @7: ifeq
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0000000: 2ab4 010c c100 0299 0017 2ab4 010c c000

Do you know how can i solve this ?

Thx

mrroboaat
  • 5,602
  • 7
  • 37
  • 65
  • You should catch that exception and call `getCause()` to retrieve the real problem. – WonderCsabo Dec 08 '14 at 11:44
  • Cause is in the trace ==> `Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 30` – mrroboaat Dec 08 '14 at 13:03
  • Yeah, you are right. It seems you are seeing a problem like in these questions http://stackoverflow.com/questions/8958267/java-lang-verifyerror-expecting-a-stackmap-frame http://stackoverflow.com/questions/15122890/java-lang-verifyerror-expecting-a-stackmap-frame-at-branch-target-jdk-1-7 http://stackoverflow.com/questions/25547401/java-lang-verifyerror-expecting-a-stackmap-frame-at-branch-target-57 – WonderCsabo Dec 08 '14 at 16:31
  • I have not this error anymore. To be sure to be on the right road. Should I buildActivity with `MapActivity_.class` or `MapActivity.class` ? It's just a pain to integrate AS + robolectric + libraries. – mrroboaat Dec 08 '14 at 17:09
  • You should test your generated class of course. For example all your view-related methods will fail with NPE with the annotated class, since the Views will not be injected. This is discussed briefly [here](https://github.com/excilys/androidannotations/wiki/Unit-test-your-application). (I'll know the code examples are not up to date with latest Robolectric, i'll update them soon). – WonderCsabo Dec 08 '14 at 20:03

0 Answers0