Android hide logs in the application when upload to market

大憨熊 提交于 2019-12-03 20:08:30
Soham

Preetha, the logs will be kept on the phone and any user/developer can check them out by installing apps like Catlog even without using adb! This is a problem as you stand to give unnecessary and at times, confidential data to users/other developers.

Simple way to solve this?

a. Use Proguard to automatically block all logs, more information in this stackoverflow thread

Here you can automatically block all logs at the bytecode level in Proguard

-assumenosideeffects class android.util.Log {
    public static int v(...);
}

The above, for example would remove any verbose logging, more in this thread

b. I use a if(DEBUG) Log.i for all my logs, so that with one change of the boolean DEBUG i can switch on/off all logs

c. A trivial solution: replace all Log.i with //Log.i :)

Yes, a good practice is to remove all the log methods called during testing,

And yes when the user downloads the application it would show all the logs to him/her that you made.

What you can do is Create a static Class with static method in that class,

when ever you want to make a log call simply call that method from anywhere by ClassName.Method

And once you are finished with testing simply COMMENT the Definition in the static method written in the Static class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!