gpt4 book ai didi

android - 将 Android Studio 更新到 ArticFox 后运行单元测试时出现 NoClassDefFoundError | 2020.3.1

转载 作者:行者123 更新时间:2023-12-05 00:11:43 25 4
gpt4 key购买 nike

未收到测试事件错误:

NoClassDefFoundError on running unit test after updating android studio to ArticFox | 2020.3.1.

下面是完整的错误:

java.lang.NoClassDefFoundError: jdk/internal/reflect/GeneratedSerializationConstructorAccessor1
at jdk.internal.reflect.GeneratedSerializationConstructorAccessor1.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:1092)
at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2180)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1679)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:493)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:122)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:68)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:73)

Caused by: java.lang.ClassNotFoundException: jdk.internal.reflect.GeneratedSerializationConstructorAccessor1
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 11 more

我刚刚下载了最新的 android studio,克隆了一个项目并尝试运行单元测试。

我该如何解决这个问题?我正在使用嵌入式 JDK(即 Java 11.0)。

最佳答案

这是由于 jacoco 而发生的。最新的 android studio 附带 Java 11,但我们使用的是 Java 9。进行以下更改修复了它。

jacoco { includeNoLocationClasses = true }

jacoco {
includeNoLocationClasses = true
excludes = ['jdk.internal.*']
}

关于android - 将 Android Studio 更新到 ArticFox 后运行单元测试时出现 NoClassDefFoundError | 2020.3.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68737413/

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