-1

Possible Duplicate:
Remove all debug logging calls before publishing: are there tools to do this?

Maybe I misunderstood the concept, but aren't debug log messages supposed to only display in the unreleased app?

I have compiled my app with "File"-"Export" which is supposed to remove all messages dumped by "Log.d(..)" of the code. However, when I run this version connected by USB while having Eclipse running, I see various debug messages openly displaying in LogCat.

I'm somewhat alarmed now - as far as I recall, ProGuard is supposed to be invoked automatically when creating release builds but it seems to leave the debug comments in the app (but otherwise seems to work as function names have been obfuscated which I can also see in Logcat).

Community
  • 1
  • 1
richey
  • 3,890
  • 9
  • 35
  • 49

3 Answers3

0

A release build will not automatically remove the Logs. And you shouldn't(recommended) remove them manually because, you need to add them back while developing for next version etc..,

The most recommended way is to use Proguard.

What it does is: Will remove logs in the bytecode, making them available in the source code.

Implementation or usage:

Remove all debug logging calls before publishing: are there tools to do this?

Other than just removing logs, proguard helps optimize your app in many ways.

http://proguard.sourceforge.net/

Community
  • 1
  • 1
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
  • But as far as I can recall, Proguard is invoked automatically when creating release builds under Eclipse? – richey Jan 09 '13 at 10:55
  • But its disabled. Moreover you need to configure it. Or at least know what basic configuration does and doesn't – Archie.bpgc Jan 09 '13 at 10:57
0

It won't remove the log statements!!! You can just remove them manually, and submit it as an update in case you published the app.

A better way would be, create a Class, like Globals, and put a flag in it, which says isDevelopement

public class Globals
{
    static boolean isDevelopment = 1;

    public static void log(String tag, String message)
    {
      if(isDevelopment==1)
         Log.d(tag,message);
    }
}

And in every place where you have the log statement, just call it like

Globals.log("TAG", "MESSAGE");

So this way, when you are publishing, you just have to change the isDevelopment to 0. And the log disappears. When you are working on it, you just have to change it to 1.

Hope this helps

nithinreddy
  • 6,167
  • 4
  • 38
  • 44
  • @nitinreddy this approach is not recommended because, here the Logs are still being created but are just not displayed. So, there wont be any performance enhancement. Its just to avoid displaying logs. Though the question is just about display, better use the best possible solution. – Archie.bpgc Jan 09 '13 at 11:01
  • You are wrong. The logs are not written in the first place. Its not about displaying, but about writing. – nithinreddy Jan 09 '13 at 12:29
0

I think I found out the cause of the problem - I had

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

in my local proguard-project.txt, but despite having the line

proguard.config=${sdk.dir}\\tools\\proguard\\proguard-android-optimize.txt:proguard-project.txt

in my project.properties file, proguard-project.txt never seems to have been used for whatever reason. I have added the Log removal parameters to my proguard-android-optimize.txt and it works now, logs are removed when exporting the app.

richey
  • 3,890
  • 9
  • 35
  • 49