Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
808 views
in Technique[技术] by (71.8m points)

android - How to recompile with -Xlint:deprecation

I don't use Android Studio but I build everything from the command line using build.gradle. I generate a Lint report like this:

./gradlew lint

This correctly generates a Lint report but it also says this:

Note: MyActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

This makes me wonder how I can do that? I've tried the following:

./gradlew lint -Xlint:deprecation

But it doesn't work. It says:

Problem configuring task :app:lint from command line.
Unknown command-line option '-X'.

So how can I pass -Xlint:deprecation to Lint via gradle?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To answer my own question, you need to add the following to your project-level build.gradle file:

allprojects {
    ...

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation"
        }
    }   
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...