java Gradle:列出已弃用的功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49304438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 10:19:37  来源:igfitidea点击:

Gradle: List deprecated features

javagradle

提问by Ed Dunn

I am getting a warning about the usage of deprecated features in my build. Is there a way to list all the deprecated features so that I may go through and update my code?

我收到有关在我的构建中使用已弃用功能的警告。有没有办法列出所有已弃用的功能,以便我可以检查并更新我的代码?

*clarification

*澄清

I know I can go to the gradle documentation and see what is now deprecated, what I would specifically like is a way to go through MY code and list out MY deprecated features.

我知道我可以转到 gradle 文档并查看现在已弃用的内容,我特别想要的是一种浏览我的代码并列出我已弃用的​​功能的方法。

回答by Hugo Allexis Cardona

I just faced the exact same problem and running the Gradle build task every time through the command line wasn't the best option for me because, during development, I usually just use the built-in Gradle build task run, so:

我只是遇到了完全相同的问题,每次通过命令行运行 Gradle 构建任务对我来说并不是最好的选择,因为在开发过程中,我通常只使用内置的 Gradle 构建任务运行,所以:

I know I can go to the Gradle documentation and see what is now deprecated, what I would specifically like is a way to go through MY code and list out MY deprecated features.

我知道我可以转到 Gradle 文档并查看现在已弃用的内容,我特别想要的是一种浏览我的代码并列出我已弃用的​​功能的方法。

You can do this by adding the mentioned --warning-mode=allflag to your gradle command line options in your Android Studio settings:

您可以通过将上述--warning-mode=all标志添加到 Android Studio 设置中的 gradle 命令行选项来执行此操作:

enter image description hereThis will print the proper warnings for you to be aware of what are the specific deprecated features your appis using.

在此处输入图片说明这将打印适当的警告,让您了解您的应用程序正在使用的特定弃用功能是什么。

Also, I know you asked this near a year ago, but, it might be useful for other people facing the same issue.

另外,我知道你在一年前问过这个问题,但是,它可能对面临同样问题的其他人有用。

回答by tangens

In order to change the warning verbosity level in the Android Studio IDE, you can add the option org.gradle.warning.mode=(all,none,summary)to the gradle.propertiesfile, which can be found in the root directory of your project.

为了在 Android Studio IDE 中更改警告详细级别,您可以将选项添加org.gradle.warning.mode=(all,none,summary)gradle.properties文件中,该文件可以在项目的根目录中找到。

Add following line to set the warning mode to all:

添加以下行以将警告模式设置为all

...
org.gradle.warning.mode=all
...

回答by VaL

Use Gradle option -Dorg.gradle.warning.mode=(all,none,summary)to control verbosity, for example, mode allwill log all warnings with detailed descriptions:

使用 Gradle 选项-Dorg.gradle.warning.mode=(all,none,summary)来控制详细程度,例如,模式all将记录所有带有详细说明的警告:

./gradlew build -Dorg.gradle.warning.mode=all

More details can be found in the official documentation: Showing or hiding warnings

更多细节可以在官方文档中找到:Showing or hidden warnings

回答by Mukesh Chauhan

  1. Go to the build.Gradle (Module) file.
  2. replace Compilewith implementation.
  3. Sync the gradle file and you will not receive the warning again.
  1. 转到 build.Gradle(模块)文件。
  2. implementation替换Compile
  3. 同步 gradle 文件,您将不会再次收到警告。