0

I have the simple Test Case

@Config(constants = BuildConfig.class)
@RunWith(RobolectricGradleTestRunner.class)
public class BaseTest  {

   @Test
   public void startEverTestSugarAppAsFirst() {
       BeaconManager.setsManifestCheckingDisabled(true);
   }

}

Unfortunately the runner hits manifestmerger issue

java.lang.RuntimeException: org.altbeacon.beacon.BeaconManager$ServiceNotDeclaredException: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true

at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:256) at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:193) at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:56) 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:159) 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:69) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) Caused by: org.altbeacon.beacon.BeaconManager$ServiceNotDeclaredException: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true at org.altbeacon.beacon.BeaconManager.verifyServiceDeclaration(BeaconManager.java:786) at org.altbeacon.beacon.BeaconManager.(BeaconManager.java:252) at org.altbeacon.beacon.BeaconManager.getInstanceForApplication(BeaconManager.java:244) at com.lucyapp.client.Client.onCreate(Client.java:67) at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:164) at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421) at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:252) ... 18 more

I wonder if there is any simple work around. I've been going through android beacon library test folder and

BeaconManager.setsManifestCheckingDisabled(true);

doesn't help

Cœur
  • 37,241
  • 25
  • 195
  • 267
speedingdeer
  • 1,236
  • 2
  • 16
  • 26

1 Answers1

0

Somehow the BeaconManager is being constructed before the call to BeaconManager.setsManifestCheckingDisabled(true); The trick is to figure out where to put that line so it does get executed first.

Looking at the stack trace, I see that the BeaconManager gets constructed from com.lucyapp.client.Client.onCreate on line 67:

...
org.altbeacon.beacon.BeaconManager.getInstanceForApplication(BeaconManager.java:244) at 
com.lucyapp.client.Client.onCreate(Client.java:67)
...

Knowing that, perhaps you can figure out where you can put the BeaconManager.setsManifestCheckingDisabled(true); line such that it gets called before com.lucyapp.client.Client.onCreate(Client.java:67)

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • I've suspected the same. Client is the android application. Seemed like I need to refactor my code a bit to make it work. If I disable the manifest check in code (just to test) I get another error in RangeNotifier. Will come back here if I have something new. – speedingdeer May 18 '16 at 22:15