我正在一个以前使用Gradle 4.6的项目中工作,并且效果很好。我刚刚更新到Gradle 5.1.1,现在收到以下警告(不过不确定是警告还是错误):
> Configure project :app
Warning: Please apply google-services plugin at the bottom of the build file.
The ProjectLayout.fileProperty() method has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory.fileProperty() method instead.
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify build listener.
> org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIdentifierImpl.getModuleIdentifier()Lorg/gradle/api/artifacts/ModuleIdentifier;
* 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
CONFIGURE FAILED in 0s
Cause: org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIdentifierImpl.getModuleIdentifier()Lorg/gradle/api/artifacts/ModuleIdentifier;
我在整个项目中搜索了ProjectLayout.fileProperty,却没有找到这样的单个字符串。 fileProperty在哪里使用,然后导致编译器抱怨?我该如何解决这些弃用警告而不是禁止它们?我需要更改代码的一部分吗?还是编译器指出的用法发生在我添加的库之一中?
答案 0 :(得分:2)
这些是警告而非错误,可以来自您自己的构建脚本,也可以来自插件。 正如它们所指示的那样,这些警告可能会在转移到下一个Gradle主版本时变成 only 错误。