How can I achieve the same what is described in the following Stack Overflow question?
How can I find all unused methods of my project in the Android Studio IDEA?
Using the command line only?
./gradlew lint ...
How can I achieve the same what is described in the following Stack Overflow question?
How can I find all unused methods of my project in the Android Studio IDEA?
Using the command line only?
./gradlew lint ...
If your project includes build variants, and you instead want to run the lint task for only a specific build variant, you must capitalize the variant name and prefix it with lint.
gradlew lintDebug
To learn more about running Gradle tasks from the command line, [read Build Your App from the Command Line.][1]
[1]: https://developer.android.com/studio/build/building-cmdline
Run lint from the command line
You can use the Gradle wrapper to invoke the lint task for your project by entering one of the following commands from the root directory of your project:
On Windows:
gradlew lint
On Linux or Mac:
./gradlew lint
You should see output similar to the following:
> Task :app:lint
Ran lint on variant release: 5 issues found
Ran lint on variant debug: 5 issues found
Wrote HTML report to file:<path-to-project>/app/build/reports/lint-results.html
Wrote XML report to file:<path-to-project>/app/build/reports/lint-results.xml
When the lint tool completes its checks, it provides paths to the XML and HTML versions of the lint report. You can then navigate to the HTML report and open it in your browser, as shown in figure 2.
Maybe try a combination of ./gradlew lint
with grep using the linux pipe symbol and filter out all of the issues related to unused methods.
./gradlew lint | grep 'unused'
you can modify the grep string per your need.
If u IntelliJ there is simple trick to find unused methods:
To run it on whole project go to Analyze -> Run inspection by name..., type Unused declaration and select desired scope. Then carefully check output and mark some classes as entry points if needed.
Now you can select Unused declaration node in list and perform Safe delete action on all unused declarations at once.
OR use ProGuard from this thread: How to find unused/dead code in java projects