[英]Android robolectric tests manifest merge issue (android beacon library)
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.
java.lang.RuntimeException:org.altbeacon.beacon.BeaconManager $ ServiceNotDeclaredException:BeaconService在AndroidManifest.xml中未正确声明。 If using Eclipse, please verify that your project.properties has manifestmerger.enabled=true
如果使用Eclipse,请验证您的project.properties是否具有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.jun
在org.robolectric.RobolectricTestRunner处$ 2.evaluate(RobolectricTestRunner.java:256)在org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:56)在org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:193)位于org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71)的org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)的.runners.ParentRunner $ 3.run(ParentRunner.java:290) 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) )在org.junit.runner.JUnitCore.run(JUnitCore.java:137)在org.junit.runners.ParentRunner.run(ParentRunner.java:363)在com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java: 69),位于com.intellij.rt.execution.jun上的com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) it.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.
it.JUnitStarter.main(JUnitStarter.java:74)位于sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)位于sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor java:43)处java.lang.reflect.Method.invoke(Method.java:497)com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)原因:org.altbeacon.beacon .BeaconManager $ ServiceNotDeclaredException:在AndroidManifest.xml中未正确声明BeaconService。 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
如果使用Eclipse,请在org.altbeacon.beacon.BeaconManager。(BeaconManager.java:252)上的org.altbeacon.beacon.Beacon.BeaconManager.verifyServiceDeclaration(BeaconManager.java:786)处验证您的project.properties是否具有manifestmerger.enabled = true。在org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:164)上的com.lucyapp.client.Client.onCreate(Client.java:67)上的org.altbeacon.beacon.BeaconManager.getInstanceForApplication(BeaconManager.java:244) )at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421)at org.robolectric.RobolectricTestRunner $ 2.evaluate(RobolectricTestRunner.java:252)...另外18个
I wonder if there is any simple work around. 我想知道是否有任何简单的解决方法。 I've been going through android beacon library test folder and
我一直在通过android beacon库test文件夹和
BeaconManager.setsManifestCheckingDisabled(true);
doesn't help 没有帮助
Somehow the BeaconManager
is being constructed before the call to BeaconManager.setsManifestCheckingDisabled(true);
不知何故
BeaconManager
被调用之前建造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: 看着堆栈跟踪,我看到
BeaconManager
会从构建com.lucyapp.client.Client.onCreate
在线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);
知道了这一点,也许您可以弄清楚可以将
BeaconManager.setsManifestCheckingDisabled(true);
放在哪里BeaconManager.setsManifestCheckingDisabled(true);
line such that it gets called before com.lucyapp.client.Client.onCreate(Client.java:67)
这样,它在
com.lucyapp.client.Client.onCreate(Client.java:67)
之前被调用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.