Khawar Raza
Khawar Raza

Reputation: 16120

Android Removal of Log.d and e.printStackTrace instructions before uploading to market

My question is simple. Should I remove Log.d/e/i/v and e.printStackTrace instructions before uploading my app to Android market?

Upvotes: 1

Views: 3340

Answers (8)

Artemiy
Artemiy

Reputation: 2792

To remove calls to the Log class add the following to the proguard-rules file:

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}

Upvotes: 0

ashishduh
ashishduh

Reputation: 6699

I just create my own Log class and build wrapper methods for the android.util.Log methods, which check BuildConfig.DEBUG before writing the log.

Upvotes: 0

Jave
Jave

Reputation: 31846

You can take a look here, they recommend that you disable the logging:

Make sure you deactivate logging and disable the debugging option before you build your application for release. You can deactivate logging by removing calls to Log methods in your source files.

However, you should keep some logging, such as printing the stack trace on exceptions etc. as you'll probably have loads of trouble debugging possible crashes later on if you remove them.

Upvotes: 0

jeet
jeet

Reputation: 29199

Log.debug instructions automatically gets remvoed when you obsufucate your application. See link:

Android Proguard, removing all Log statements and merging packages

Upvotes: 2

Saurabh Verma
Saurabh Verma

Reputation: 6728

OfCource you should, especially if your application relies a lot on performance (eg a game having fast frame rate), otherwise the printing of logs eats up a lot of performance The correct way to do this is to have a flag something like isLoggable, which if set to false wont print the logs.

Upvotes: 1

user370305
user370305

Reputation: 109237

If possible yes, Its a good application development practice, But proper handle of e.printStack is necessary to prevent your application force close from un necessary exception. For this you can use Log.e(TAG, e.toString()); in all catch block. This will be keep some necessary information about your application behavior and you can also easily get information about any force-close or exception for your application.

Upvotes: 5

Bigflow
Bigflow

Reputation: 3666

I don't know if you must delete it. If I upload a project into the market, I got 2 version of the same app.

  1. with println and logs
  2. without println and logs

removing them will always make the app go a little quicker (very little).

Upvotes: 0

qdot
qdot

Reputation: 6335

It really depends on the lifecycle of the application after it gets released to the market.

If you cannot trust your users to provide detailed bug reports (generally speaking, with engineering-related apps you can hope that some users would have the acumen to submit detailed crash report), then there is no reason to bloat the Android Log.

On the other hand, some bugs are heisenbugs and might disappear after you add logging statements, making them really difficult to find.

It's really a matter of taste - I provide a build-time switch that includes them in debug builds, but not in release builds. And I usually wait until the app is past beta to disable debug log completely.

Upvotes: 0

Related Questions