Android Robolectric测试清单合并问题(Android信标库) [英] Android robolectric tests manifest merge issue (android beacon library)
问题描述
我有简单的测试用例
@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:
BeaconService不正确在AndroidManifest.xml中声明。如果
使用Eclipse,请验证您的project.properties具有
manifestmerger.enabled = true
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
在
org.robolectric.RobolectricTestRunner $ 2.evaluate(RobolectricTestRunner.java:256)
at
org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:193)
at
org.robolectric.RobolectricTestRunner.runChild( RobolectricTestRunner.java:56)
在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:290)在
org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71)在
org处
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)在
org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:58)中。 junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:268)在
org.robolectric.RobolectricTestRunner $ 1.evaluate(RobolectricTestRunner.java:159)
在org.junit.runners.ParentRunner.run( ParentRunner.java:363),位于
org.junit.runner.JUnitCore.run (JUnitCore.java:137)在
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
在
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart (JUnitStarter.java:234)
在
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
在sun.reflect.NativeMethodAccessorImpl.invoke0(Native在
处的方法)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在
处的
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java .lang.reflect.Method.invoke(Method.java:497)at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
原因:
org.altbeacon.beacon.BeaconManager $ ServiceNotDeclaredException:
BeaconService在AndroidManifest.xml中未正确声明。如果
使用Eclipse,请验证您的project.properties在
处具有
manifestmerger.enabled = true org.altbeacon.beacon.BeaconManager.verifyServiceDeclaration(BeaconManager.java:786)
在org.altbeacon.beacon.BeaconManager。(BeaconManager.java:252)在
处
org.altbeacon.beacon.BeaconManager.getInstanceForApplication(BeaconManager.java:244)
在com.lucyapp。在
的client.Client.onCreate(Client.java:67)org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:164)在
的
org.robolectric.RobolectricTestRunner.setUpApplicationState( RobolectricTestRunner.java:421)
at
org.robolectric.RobolectricTestRunner $ 2.evaluate(RobolectricTestRunner.java:252)
... 18个其他
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
我想知道是否有任何简单的解决方法。我一直在浏览android beacon库测试文件夹和
I wonder if there is any simple work around. I've been going through android beacon library test folder and
BeaconManager.setsManifestCheckingDisabled(true);
没有帮助
推荐答案
以某种方式在调用 BeaconManager.setsManifestCheckingDisabled(true)之前,构造
诀窍是弄清楚该行的位置,以便它首先得到执行。 BeaconManager
。 ;
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.
看一下堆栈跟踪,我看到了 BeaconManager
从第67行的 com.lucyapp.client.Client.onCreate
构造:
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)
...
知道,也许您可以找出可以将 BeaconManager.setsManifestCheckingDisabled(true);
行放在哪里,以便在 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)
这篇关于Android Robolectric测试清单合并问题(Android信标库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!