Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
升级到Gradle 5.0后弹出的恼人提示_Gradle_Kotlin - Fatal编程技术网

升级到Gradle 5.0后弹出的恼人提示

升级到Gradle 5.0后弹出的恼人提示,gradle,kotlin,Gradle,Kotlin,刚刚更新到Gradle 5.0,现在我得到了: 为什么??我该如何解决呢?您没有真正需要担心的问题。根据您更新的问题和屏幕截图,您会弹出一个不正确的IDE静态分析提示。您没有来自Gradle的任何错误或警告消息。您的文本编辑器中存在误导性的内容 当显示的代码(例如,build.gradle是Groovy代码)无法完全解释以了解正确的类型时,就会发生这种情况。在这种情况下,没有任何问题。这是一个骗局,应该被忽略 您可以安全地忽略此IDE消息,您将在build.gradle文件上不时收到其他误导性消

刚刚更新到Gradle 5.0,现在我得到了:


为什么??我该如何解决呢?

您没有真正需要担心的问题。根据您更新的问题和屏幕截图,您会弹出一个不正确的IDE静态分析提示。您没有来自Gradle的任何错误或警告消息。您的文本编辑器中存在误导性的内容

当显示的代码(例如,
build.gradle
是Groovy代码)无法完全解释以了解正确的类型时,就会发生这种情况。在这种情况下,没有任何问题。这是一个骗局,应该被忽略

您可以安全地忽略此IDE消息,您将在
build.gradle
文件上不时收到其他误导性消息。如果您想在编写生成文件时获得正确的IDE帮助,请切换到完全类型安全的Kotlin版本的gradle生成文件。Groovy版本在IDE中对于您收到的消息来说从来都不是完美的

在空目录上测试您的
build.gradle

$ ./gradlew build

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 0s
7 actionable tasks: 2 executed, 5 up-to-date
并直接从GitHub repo测试它:(注意:在警告中有一些危险的类路径问题,应该解决)

请注意,Gradle未报告任何消息或错误。只有您的IDE是可用的。

将其替换为:

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.10"

然后没有被使用。

您需要将警告模式更改为全部或无以避免提示


org.gradle.warning.mode=all
org.gradle.warning.mode=none
添加到您的
gradle.properties

我在一个空目录中尝试了您的构建文件,其中包含了gradle 4.10.x和5.0,两者都可以正常工作。您是否使用特定的JDK运行Gradle?你在运行你认为你是的Gradle版本吗?您是否正在运行带有特定任务的Gradle?是否有settings.Gradle文件?gradle.properties文件?你能把它们也拿出来看看吗。我想我运行5.0是因为我可以看到以前从未见过的新输出:“此版本中使用了不推荐的Gradle功能,使其与Gradle 6.0不兼容。”当然,我只是,
gradle5.0
分支。附言:使用Idea 2018.3,您的机器上还有其他一些环境问题,因为该分支运行良好,并且在单元测试中失败。我自己也注意到了这一点。有趣的是,
master
4.10.2
一起工作是完美的。类路径问题来自于,我要明确的是,这就是我所说的警告。请注意,我在
5.0
中也遇到过测试失败的情况。您应该将问题更新为“error”或“warning”,因为“error/warning”远不清楚。另外,显示实际的错误或警告,而不是仅仅指出存在错误或警告。您这里有一个问题,您应该解决,包括两个版本的Kotlin库的依赖关系,以及您的系统产生不应该发生的异常消息。好的,我更新了问题,删除了
错误
,并将屏幕截图设置为
警告
,以清楚显示我的问题。关于依赖性问题,我刚才提前回复了两条评论,这超出了我的范围(或者至少看起来是这样)。@elect您可以强制Kotlin库上的版本为当前版本,它在您的范围内。只需使用正确的版本号将依赖项添加到您的中,就可以强制将它们添加到您的中。它不应该影响测试库。这似乎就是原因。另外,这是更好的:
implementation“org.jetbrains.kotlin:kotlin stdlib:$kotlin_version.toString()
这不是使用非惯用代码删除警告的好建议。如果您注意到,在干净的系统上运行时,这些错误或警告不会出现。@JaysonMinard虽然它避免了问题,但这是完全正确的。我直接编辑了答案,告诉我这是否合适,让大家现在都很开心:)
$ ./gradlew clean build
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.2.50/9fab8887f91c8e17cce1a7522f45dc25976e57b9/kotlin-reflect-1.2.50.jar (version 1.2)
    /Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.31/95d6a67e8787280a82a2059e54e4db7ac6cfe74/kotlin-stdlib-jdk7-1.2.31.jar (version 1.2)
    /Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.10/b178c1501609c6e4ee8be635513cb023a466457d/kotlin-stdlib-1.3.10.jar (version 1.3)
    /Users/xyz/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.10/1b19d99229dcedad7caf50534dce38fe82845269/kotlin-stdlib-common-1.3.10.jar (version 1.3)
w: Consider providing an explicit dependency on kotlin-reflect 1.3 to prevent strange errors
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

> Task :test FAILED

unsigned.Ubyte test > ubyte FAILED
    org.opentest4j.AssertionFailedError at ubyte.kt:35

unsigned.Uint test > uint FAILED
    org.opentest4j.AssertionFailedError at uint.kt:32

unsigned.Ulong test > ulong FAILED
    org.opentest4j.AssertionFailedError at ulong.kt:29

unsigned.Ushort test > ushort FAILED
    org.opentest4j.AssertionFailedError at ushort.kt:30

6 tests completed, 4 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/xyz/.../kotlin-unsigned/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
10 actionable tasks: 10 executed
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.10"