3
  • I have used many logs in project which i want to remove
  • Is there a way to find all the Log.d() lines in android studio using a find method
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Devrath
  • 42,072
  • 54
  • 195
  • 297

3 Answers3

6
  1. Bring up "Find in Path" using Edit > Find > Find In Path... (ctrl + shift + F)

  2. Search for Log.d in the search box. You can limit the files to search for using the File mask option in the top right e.g. to limit your search to .java files.

  3. Press ctrl + enter. This will now show your results in the Search panel.

Alternatively, use an alternative logging library such as Timber that won't dump out debug logs in user builds.

Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
5

You can use Ctrl+Shift+F and then type in "Log.d(", that will show you the places where it's being used.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Usman Rafi
  • 316
  • 1
  • 2
  • 12
3

Instead of removing all Log.d() calls manually you can edit your proguard-rules.pro file to include the following lines:

-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}

It will make the functions Log.d() and Log.v() empty, generating no logs in your release apk.

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62