3

Android app submission says, remove any logging before submission. Have a few question on this one

  1. Is System.out.println considered as logging? How can I disable it across the app without having to remove it on by one
  2. Tried android:debuggable="false" inside manifest, but eclipse says "Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one"
  3. I have some third party jar files that shows Log statement when I test my app. How can I remove them, considering I don't have the source.

Suggestions are highly appreciated.

Mat
  • 202,337
  • 40
  • 393
  • 406
Veeru
  • 4,936
  • 2
  • 43
  • 61
  • Not sure about disabling it, but you could do a replaceAll of some kind. The `debuggable="false"`attribute is how I used to do it, but it's been a while since I used android. – keyser Oct 14 '12 at 08:56
  • Yeah, as i mentioned eclipse warns me to not add debuggable attribute. This is my first app submission, so trying to get my head clear about what needs to be done. A mass search/replace might be good, but what if i want the log commands to be there for debugging in future? – Veeru Oct 14 '12 at 10:53

1 Answers1

2

I'm sure you've come across the fact that you can do the if(GLOBAL_VALUE) trick, because your logs are already there!

Therefore, my suggestions is to use Proguard; http://developer.android.com/tools/help/proguard.html

The following proguard.cfg chunk instructs to remove Log.d calls.

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

You can do it for other calls like Log.i, Log.e, etc based on the value you put there!

As for your Jar, if it is referencing the Android Log system, ProGuard should take care of that.

keyser
  • 18,829
  • 16
  • 59
  • 101
programmer33
  • 642
  • 8
  • 19
  • Thanks Richard. I seem to be having a problem trying to configure proguard, my project does'nt have a proguard.cfg, update command did'nt help as well. My sdk is up-to-date. How can i activate proguard in my project? – Veeru Oct 14 '12 at 10:52
  • Hi Veeru, if you don't have .cfg file, perhaps you are on the newer ADT version (17+) ... if you are, this article will help ! http://tools.android.com/recent/proguardimprovements – programmer33 Oct 14 '12 at 19:58
  • Do you still have any problems with logging Veeru? – programmer33 Oct 15 '12 at 23:35
  • Hey Richard, am tryign to get proguard running, i am having issues. Thought of giving it my best shot before posting results/problems – Veeru Oct 16 '12 at 03:16
  • Sorry for being a noob here, never used proguard before. WIth proguard.cfg how do i remove System.out.println statements? – Veeru Oct 17 '12 at 02:14
  • 1
    No worroes, if I recall correctly Proguard is for android-specific settings .. For removing (and doing so safely) of system.out.println's see this post about a generic java question! http://stackoverflow.com/a/572222/1387888 hope it helps – programmer33 Oct 17 '12 at 18:58
  • 1
    Are you ok with this implementation Veeru, do you need any help? – programmer33 Oct 19 '12 at 05:47
  • Hi Richard, Thanks a lot for your concern. I was having trouble getting proguard running. I am on a tight timeline, so i manually removed all System.out.println statements and submitted app without proguard. Now i take my time and understand usage of proguard. By the way, 2 upvotes for you, especially for your concern. – Veeru Oct 20 '12 at 12:40
  • Richard, i will definitely get back onto this thread. Am trying, progaurd throws errors when exporting the apk, all the paths are fine, am trying to see if i can find a solution for it, checking if my paths are right. – Veeru Oct 20 '12 at 16:14
  • No problem, just wanted to follow through :) paths are confusing at times as well, let me know if you have questions – programmer33 Oct 21 '12 at 11:46