Office Hours — Today, May 3

Yesterday, May 2

May 3
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:00 PM
Ettie S.
has entered the room
Mark M.
hello, Ettie!
how can I help you today?
Ettie S.
Hello Mr. Murphy. I had a question about logs showing up after using Proguard.
4:05 PM
Ettie S.
The file I uploaded is a sample of what I could see on the logcat for Samsung Calendar.
I set up Proguard for my app, but on my release version, I can see similar items in logcat related to my app, but I also saw some logging that was done with Log.d in my app.
Mark M.
ProGuard does not automatically remove logging statements
in part, because ProGuard is a plain Java tool, and it knows nothing about Android's Log class
Ettie S.
Right, so I added this to my proguard rules:
View paste
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** w(...);
    public static *** v(...);
    public static *** i(...);
    public static *** e(...);
}
But for some reason my Log.d shows when I access a url and prints the url.
Any ideas?
Mark M.
not off the top of my head
I haven't tried using -assumenosideeffects
4:10 PM
Mark M.
this is old, but the person answering the question is the developer of ProGuard
see also https://stackoverflow.com/a/32858681/115145 -- are you using proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
Ettie S.
Thanks. I guess I'll be altering my code.
No, I use getDefaultProguardFile('proguard-android.txt')
Mark M.
ah, then that may be your problem
Ettie S.
Does that mean I should create such a file?
Mark M.
no, the build tools already ship with it
add the -optimize to the filename
Ettie S.
Just alter the filename? Sounds simple enough.
Mark M.
note that this is much more aggressive than your existing ProGuard configuration, so you may get more build errors that you have to work through
nothing with ProGuard is "simple enough" IMHO :-)
Ettie S.
Thanks.
4:15 PM
Ettie S.
That's true.
So is there a simpler way to hide the logs for an app release -- or is commenting them all out really the best way?
Mark M.
well, in principle, the approach that you are using appears like it should work, if you use the -optimize edition of the default rules
leastways, a bunch of people on Stack Overflow and elsewhere refer to it
another approach that people have used is to wrap all Log calls in an if() check against a constant, such as BuildConfig.DEBUG
so, instead of Log.d("App", "yo!");, you have if (BuildConfig.DEBUG) { Log.d("App", "yo!"); }
Ettie S.
Sounds good. Quick question about that: when I "search everywhere" for the -optimize file, why do I see the file as proguard-android-optimize.txt-3.0.0? Should I put that down in the gradle file?
Mark M.
I don't think so
that might be tied to build tools versions or something
Ettie S.
Thanks. I think I'll stick to the second approach you said, with BuildConfig.
Mark M.
the syntax that I have always seen for getDefaultProguardFile() never uses a version number
Ettie S.
Me neither, so it was surprising to see it come up that way.
Mark M.
my point is that the numbers might be added by the getDefaultProguardFile() method
4:20 PM
Mark M.
so, your build.gradle does not include the numbers, but the build tools add them
that's just an educated guess
Ettie S.
Thanks.
It's just funny that the only logs to show from my app that aren't like what I uploaded were api calls. By the way, the logs I uploaded, what kind of information is that?
Mark M.
you'd have to ask Samsung
Ettie S.
Ok. Thanks. I saw similar logging when I opened other apps on my phone and got similar results, showing what classes where opened and the like.
Maybe because my device has developer options enabled....
Mark M.
particularly for pre-installed apps, device manufacturers historically have not cared about what they log
this is one of the reasons why apps do not have read access to logs at runtime
Ettie S.
Ok. I saw it with apps from the Play Store as well, but as long as it's nothing important.
Thank you very much for your help.
Mark M.
you're welcome!
Ettie S.
has left the room
4:55 PM
Alex
has entered the room
Alex
Hello hello!
5:00 PM
Mark M.
hello!
um, except that the chat is scheduled to end right about now
Alex
How are you today?
Nooo
I knew I was late
I've been waiting all week
Dang
Mark M.
the chat started an hour ago
do you have a really quick question?
Alex
Yes, I know
Maybe, I'll ask. If you think it's worth answering then answer
If not tell me to come back
You know what
I'll wait and formulate the question better
Mark M.
OK
Alex
I'll see you next time
Mark M.
the next chat is Monday at 7:30pm US Eastern
Alex
Okay
Take care
Mark M.
you too!
Alex
has left the room
Mark M.
turned off guest access

Yesterday, May 2

 

Office Hours

People in this transcript

  • Alex
  • Ettie Schreiber
  • Mark Murphy

Files in this transcript