android 发布时去除Log

1) project.properties文件里,去掉下面一行的注释:

# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

 

2) proguard-project.txt文件里,加入:

-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}

 

3) 通过如下图所示的方法将apk导出,不能通过运行eclipse中的Run as 和 Debug as 菜单来生成,当然你可以选择“签名”或者“不签名”,选择“签名”需要输入一堆信息:

android 发布时去除Log_第1张图片

你可能感兴趣的:(android)