gpt4 book ai didi

java - 将 Android Studio 升级到 4.0 后,我得到 'Caused by: java.lang.IllegalStateException: Unexpected non-class file'

转载 作者:行者123 更新时间:2023-12-01 13:57:48 26 4
gpt4 key购买 nike

当我尝试使用 Android Studio 4.0 运行仪器测试时,我得到

Caused by: java.lang.IllegalStateException: Unexpected non-class file: META-INF\versions\9\org\junit\platform\commons\util\ModuleUtils$ModuleReferenceScanner.class
直到我将 Android Studio 从 3.x 升级到 4.0 才发生这种情况。
有人解决了吗?提前致谢。

最佳答案

这是我想出的解决问题的技巧……我认为不需要这些类文件,删除它们似乎不会造成任何问题。

/**
* Hack to work around this problem: https://stackoverflow.com/q/62540396
* I don't think we use these class files at all so we can just delete them before dexing. I tried to see if we could
* configure the file collection to exclude them instead, but it's actually just a collection of folders, which
* internally the task just traverses separately.
*/
allprojects {
tasks.withType<DexArchiveBuilderTask> {
doFirst {
mixedScopeClasses
.asFileTree
.matching { include("**/META-INF/versions/9/**/*.class") }
.forEach { it.delete() }
}
}
}
(这是 Kotlin - 如果你使用 Groovy 会略有不同)

关于java - 将 Android Studio 升级到 4.0 后,我得到 'Caused by: java.lang.IllegalStateException: Unexpected non-class file',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62540396/

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