gpt4 book ai didi

android - CI 环境中的 Robolectric

转载 作者:行者123 更新时间:2023-11-29 00:10:09 26 4
gpt4 key购买 nike

我遇到了一个问题,我的 robolectric 测试通过了我的终端:./gradlew 测试和相同的命令,使用 circleci 上的所有工具正确配置给我这个错误:

java.lang.RuntimeException: java.lang.IllegalArgumentException: maxSize <= 0
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.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
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 org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
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 org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: maxSize <= 0
at com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache.<init>(LruMemoryCache.java:33)
at com.nostra13.universalimageloader.core.DefaultConfigurationFactory.createMemoryCache(DefaultConfigurationFactory.java:114)
at com.nostra13.universalimageloader.core.ImageLoaderConfiguration$Builder.initEmptyFieldsWithDefaultValues(ImageLoaderConfiguration.java:584)
at com.nostra13.universalimageloader.core.ImageLoaderConfiguration$Builder.build(ImageLoaderConfiguration.java:559)
at com.heetch.HeetchApp.initImageLoader(HeetchApp.java:123)
at com.heetch.HeetchApp.onCreate(HeetchApp.java:55)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234)
... 34 more

我正在使用 robolectric 3.0-rc3,我相信这个错误来自 robolectric 本身,但我不知道从哪里寻找解决这个错误的任何线索。

最佳答案

解决方案是向 ImageLoader 添加内存缓存,如下所示:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.memoryCache(new WeakMemoryCache())
.build();

关于android - CI 环境中的 Robolectric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30943288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com