May 3 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
May 3 | 4:00 PM |
Ettie S. | has entered the room |
Mark M. |
hello, Ettie!
|
Mark M. |
how can I help you today?
|
Ettie S. | |
Ettie S. |
Hello Mr. Murphy. I had a question about logs showing up after using Proguard.
|
May 3 | 4:05 PM |
Ettie S. |
The file I uploaded is a sample of what I could see on the logcat for Samsung Calendar.
|
Ettie S. |
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
|
Mark M. |
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:
|
Ettie S. |
View paste
|
Ettie S. |
But for some reason my Log.d shows when I access a url and prints the url.
|
Ettie S. |
Any ideas?
|
Mark M. |
not off the top of my head
|
Mark M. |
I haven't tried using -assumenosideeffects
|
May 3 | 4:10 PM |
Mark M. | |
Mark M. |
this is old, but the person answering the question is the developer of ProGuard
|
Mark M. |
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.
|
Ettie S. |
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
|
Mark M. |
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
|
Mark M. |
nothing with ProGuard is "simple enough" IMHO :-)
|
Ettie S. |
Thanks.
|
May 3 | 4:15 PM |
Ettie S. |
That's true.
|
Ettie S. |
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
|
Mark M. |
leastways, a bunch of people on Stack Overflow and elsewhere refer to it
|
Mark M. |
another approach that people have used is to wrap all Log calls in an if() check against a constant, such as BuildConfig.DEBUG
|
Mark M. |
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
|
Mark M. |
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
|
May 3 | 4:20 PM |
Mark M. |
so, your build.gradle does not include the numbers, but the build tools add them
|
Mark M. |
that's just an educated guess
|
Ettie S. |
Thanks.
|
Ettie S. |
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.
|
Ettie S. |
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
|
Mark M. |
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.
|
Ettie S. |
Thank you very much for your help.
|
Mark M. |
you're welcome!
|
Ettie S. | has left the room |
May 3 | 4:55 PM |
Alex | has entered the room |
Alex |
Hello hello!
|
May 3 | 5:00 PM |
Mark M. |
hello!
|
Mark M. |
um, except that the chat is scheduled to end right about now
|
Alex |
How are you today?
|
Alex |
Nooo
|
Alex |
I knew I was late
|
Alex |
I've been waiting all week
|
Alex |
Dang
|
Mark M. |
the chat started an hour ago
|
Mark M. |
do you have a really quick question?
|
Alex |
Yes, I know
|
Alex |
Maybe, I'll ask. If you think it's worth answering then answer
|
Alex |
If not tell me to come back
|
Alex |
You know what
|
Alex |
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
|
Alex |
Take care
|
Mark M. |
you too!
|
Alex | has left the room |
Mark M. | turned off guest access |