gpt4 book ai didi

java - 缩短命令行后无法运行测试

转载 作者:行者123 更新时间:2023-11-28 21:38:06 25 4
gpt4 key购买 nike

我尝试运行一些测试,但收到一条错误消息,指出类路径太长。所以在设置中我设置了 classpath file 选项来缩短它。现在在尝试测试时出现错误:

java.lang.RuntimeException: java.lang.ClassNotFoundException: org.robolectric.android.internal.ParallelUniverse

at org.robolectric.RobolectricTestRunner.getHooksInterface(RobolectricTestRunner.java:556)
at org.robolectric.RobolectricTestRunner.configureSandbox(RobolectricTestRunner.java:235)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:230)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
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:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
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:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)
Caused by: java.lang.ClassNotFoundException: org.robolectric.android.internal.ParallelUniverse
at org.robolectric.internal.bytecode.SandboxClassLoader.getByteCode(SandboxClassLoader.java:163)
at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:118)
at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:111)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:110)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.robolectric.RobolectricTestRunner.getHooksInterface(RobolectricTestRunner.java:551)
... 21 more

我对如何解决这个问题做了一些研究,我发现我应该使缓存无效并重新启动(这没有用)并将类路径缩短选项更改为 JAR manifest。在尝试了后者之后,我现在遇到了新的错误:

java.lang.VerifyError: Expecting a stackmap frame at branch target 5
Exception Details:
Location:
com/appsflyer/MultipleInstallBroadcastReceiver.onReceive(Landroid/content/Context;Landroid/content/Intent;)V @1: ifnonnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0x0000000: 2cc7 0004 b12c 1207 b600 2359 4ec6 003a
0x0000010: 1201 2db6 002d 9900 152c 1203 b600 23c6
0x0000020: 000c b800 272b 2cb6 0029 b12b 1204 03b6
0x0000030: 0020 1207 01b9 0032 0300 c600 0db8 0027
0x0000040: 572b 2db8 0028 b112 02b8 0026 b800 272b
0x0000050: 2cb6 0029 2bb6 001e bb00 0b59 1205 b700
0x0000060: 2103 b600 24b9 0035 0100 4e2d b900 3301
0x0000070: 0099 0099 2db9 0034 0100 c000 0f3a 042c
0x0000080: b600 223a 0519 04b4 001b b400 1a2b b600
0x0000090: 1fb6 002d 9900 7312 0519 05b6 002d 9900
0x00000a0: 692a b600 2eb6 002b 1904 b400 1bb4 0019
0x00000b0: b600 2d9a 0054 bb00 1559 1208 b700 3019
0x00000c0: 04b4 001b b400 19b6 0031 b600 2fb8 0026
0x00000d0: 1904 b400 1bb4 0019 b800 2ab6 002c c000
0x00000e0: 092b 2cb6 001d a7ff 853a 05bb 0015 5912
0x00000f0: 06b7 0030 1904 b400 1bb4 0019 b600 31b6
0x0000100: 002f 1905 b800 25a7 ff64 b1
Exception Handler Table:
bci [208, 230] => handler: 233


at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.robolectric.util.ReflectionHelpers.callConstructor(ReflectionHelpers.java:377)
at org.robolectric.internal.bytecode.ShadowImpl.newInstanceOf(ShadowImpl.java:24)
at org.robolectric.shadow.api.Shadow.newInstanceOf(Shadow.java:35)
at org.robolectric.android.internal.ParallelUniverse.registerBroadcastReceivers(ParallelUniverse.java:439)
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:235)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:379)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:252)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
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:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

在那之后我决定更新 Roboletric 库,现在我遇到了这样的错误:

java.lang.IllegalArgumentException: URI is not hierarchical

at sun.nio.fs.WindowsUriSupport.fromUri(WindowsUriSupport.java:122)
at sun.nio.fs.WindowsFileSystemProvider.getPath(WindowsFileSystemProvider.java:92)
at java.nio.file.Paths.get(Paths.java:138)
at org.robolectric.util.Util.pathFrom(Util.java:98)
at org.robolectric.plugins.DefaultSdkProvider$DefaultSdk.getJarPath(DefaultSdkProvider.java:120)
at org.robolectric.internal.AndroidSandbox$SdkSandboxClassLoader.<init>(AndroidSandbox.java:97)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.robolectric.util.inject.Injector.inject(Injector.java:239)
at org.robolectric.util.inject.Injector.lambda$memoized$1(Injector.java:221)
at org.robolectric.util.inject.Injector$MemoizingProvider.get(Injector.java:486)
at org.robolectric.util.inject.Injector.getInstanceInternal(Injector.java:213)
at org.robolectric.util.inject.Injector.resolveDependencies(Injector.java:284)
at org.robolectric.util.inject.Injector.inject(Injector.java:237)
at org.robolectric.util.inject.Injector.lambda$memoized$1(Injector.java:221)
at org.robolectric.util.inject.Injector$MemoizingProvider.get(Injector.java:486)
at org.robolectric.util.inject.Injector.getInstanceInternal(Injector.java:213)
at org.robolectric.util.inject.Injector.getInstance(Injector.java:197)
at org.robolectric.util.inject.Injector.access$700(Injector.java:85)
at org.robolectric.util.inject.Injector$ScopeBuilderProvider.create(Injector.java:552)
at org.robolectric.util.inject.Injector$ScopeBuilderProvider.lambda$get$0(Injector.java:535)
at com.sun.proxy.$Proxy10.build(Unknown Source)
at org.robolectric.internal.SandboxManager.getAndroidSandbox(SandboxManager.java:53)
at org.robolectric.RobolectricTestRunner.getSandbox(RobolectricTestRunner.java:263)
at org.robolectric.RobolectricTestRunner.getSandbox(RobolectricTestRunner.java:62)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:219)
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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:100)
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:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

那么我怎样才能以某种方式修复我当前的情况并运行这些测试呢?

最佳答案

这不是您的 Jar list 问题的答案,而是一种修复长类路径的方法。由于 java6 允许使用通配符,并且它使路径(在大多数情况下)更短。

https://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html#Understanding

关于java - 缩短命令行后无法运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55826199/

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