I'm posting this solution which applies specifically for Android Studio users. I also recently discovered Timber and have imported it successfully into my app by doing the following:
Put the latest version of the library into your build.gradle:
compile 'com.jakewharton.timber:timber:4.1.1'
Then in Android Studios, go to Edit -> Find -> Replace in Path...
Type in Log.e(TAG,
or however you have defined your Log messages into the "Text to find"
textbox. Then you just replace it with Timber.e(
Click Find and then replace all.
Android Studios will now go through all your files in your project and replace all the Logs with Timbers.
The only problem I had with this method is that gradle does come up witha million error messages afterwards because it cannot find "Timber" in the imports for each of your java files. Just click on the errors and Android Studios will automatically import "Timber" into your java. Once you have done it for all your errors files, gradle will compile again.
You also need to put this piece of code in your onCreate
method of your Application
class:
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
This will result in the app logging only when you are in development mode not in production. You can also have BuildConfig.RELEASE
for logging in release mode.