0

I am using the method suggested here to get rid of the Logs in my release APK. I use the following config for that:

-dontskipnonpubliclibraryclasses
-dontobfuscate
-forceprocessing
-optimizationpasses 5
-keepattributes
-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(...);
}

This works when it comes to my own Log calls. However, I link to a library in my project, which is also in my Workspace. As far as I know this config should apply for the linked library too. But the Log.d(...) outputs from the linked library are still there when I run the release APK on my USB connected device. I cannot get them stripped out. Why not?

BTW, I use the right click -> android tools -> Export signed APK method in Eclipse ADT bundle for generating the release APK.

Community
  • 1
  • 1
ercan
  • 1,639
  • 1
  • 20
  • 34

1 Answers1

1

To remove logging, you need to make sure that ProGuard's optimization step is enabled. It is disabled in the default configuration file in the Android SDK. Replace proguard-android.txt by proguard-android-optimize.txt in your project.properties:

proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt

Note that ProGuard doesn't make any distinction between your code and library code.

Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • Thanks for the information. I find this strange because using just `proguard-android.txt` _DID_ remove the logs from _my own project_. But the log outputs from the linked project were still printing. This contradicts with the comment "ProGuard doesn't make any distinction between your code and library code". But anyway, I changed the `proguard-android.txt` to `proguard-android-optimize.txt` and now I'm fighting with another error, which is _"conversion to dalvik format failed with error -1"_ – ercan Mar 13 '14 at 09:11
  • Ok, I solved the problem with the help of the hint I found here: http://viktorbresan.blogspot.com.tr/2012/10/conversion-to-dalvik-format-failed-with.html#comment-form . Now there is no Log output anymore. Thanks a lot! – ercan Mar 13 '14 at 09:35