Questions tagged [proguard]

ProGuard is a tool to shrink, optimize, obfuscate, and preverify Java classes. It is included in the Android SDK.

ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names. Finally, it preverifies the processed code for Java 6 or for Java Micro Edition.

ProGuard is a command-line tool with an optional graphical user interface and with a plugin for Ant. ProGuard is integrated in Google's Android SDK, where it can be enabled for creating releases, from the command-line or in Eclipse. It is also supported in many development environments for Java Micro Edition.

Proguard is developed by Eric Lafortune and officially supported by GuardSquare.

4366 questions
41
votes
2 answers

Android ProGuard return Line Number

Is there a way to get ProGuard to return a line number where the crash happened? I can use retrace to get to the method, but often for things like NullPointerException there are too many possibilities and in a large piece of code its extremely hard…
Ali
  • 12,354
  • 9
  • 54
  • 83
40
votes
16 answers

Reducing android app (apk) size

I would be now publishing my first app on Google play store. I have already compressed images used in my app. And I have some questions regarding the app size. If the size of app is less that 2 MB then there are less chances that user will uninstall…
Vivek Warde
  • 1,936
  • 8
  • 47
  • 77
39
votes
1 answer

Android ProGuard - only obfuscation

Is it possible to use ProGuard for only obfuscation. I don't want ProGuard to remove any classes from my projects. My intention to use ProGuard is only for obfuscation so as to prevent reverse engineering.
Vinoth
  • 5,687
  • 11
  • 44
  • 56
39
votes
4 answers

Android Proguard Javascript Interface Fail

I use in my project a piece of code as described here http://lexandera.com/2009/01/extracting-html-from-a-webview/ I create the .apk file, install it on my device and it correctly works. If I try to use the obfuscation with proguard the project…
Denis
  • 423
  • 1
  • 5
  • 9
39
votes
3 answers

Proguard and reflection in Android

I have just used proguard, but classes I am trying to instantiate via reflection are not working. I have an interface Algorithm I pass classes like this AlgorithmFactory.SomeClassThatExtendsAlgorithmImpl.class The class is instantiated like…
jax
  • 37,735
  • 57
  • 182
  • 278
39
votes
5 answers

Proguard warnings "can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry)"

I'm using IntelliJ and running Proguard in debug mode but I can't seem to get rid of warnings such as: ProGuard: [MyApplication] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
38
votes
10 answers

ProGuard configuration for Guava with obfuscation and optimization

Looking for a ProGuard configuration for Guava that will obfuscate and optimize, as the default one that is provided on the website does not. Not only that I cannot get it to export my apk, I keep getting: Warning:…
user1159819
  • 1,549
  • 4
  • 16
  • 29
38
votes
4 answers

When obfuscating with ProGuard, does -keepattributes SourceFile,LineNumberTable make the resulting apk easier to reverse engineer?

I find myself needing more detail in my reported stack traces, but I'm concerned that by including the extra data (by using -keepattributes SourceFile,LineNumberTable) I'm making my app even easier to reverse engineer. Is this the case, and if so,…
wirbly
  • 2,183
  • 1
  • 24
  • 24
38
votes
1 answer

How to tell ProGuard to keep private fields without specifying each field

This is my class: package com.tools.app.holiday; public class Holiday { private String name; private Calendar dateFrom = Calendar.getInstance(); private Calendar dateTo = Calendar.getInstance(); ... I can keep these private…
cja
  • 9,512
  • 21
  • 75
  • 129
36
votes
1 answer

proguard-android-optimize.txt vs proguard-android.txt in Android build.gradle

I was reading the docs about shrinking, obfuscating and optimising for a release build using build.gradle for an Android app. In one section of the docs, proguard-android.txt is used as the defauly ProGuard file: android { ... buildTypes { …
James Allen
  • 6,406
  • 8
  • 50
  • 83
36
votes
1 answer

How can I obfuscate only com.foo.* and com.bar.* (ProGuard)?

I want to obfuscate only some packages: com.foo.* com.bar.* I have tried -keepclasseswithmembers class **, !com.foo.**, !com.bar.** { *; } and -keepclasseswithmembers class !com.foo.** { *; } -keepclasseswithmembers class !com.bar.** { *; } In…
alex2k8
  • 42,496
  • 57
  • 170
  • 221
36
votes
1 answer

ProGuard Cannot Find Referenced Libraries

[2014-07-15 23:57:43 - MozMeet] Proguard returned with error code 1. See console [2014-07-15 23:57:43 - MozMeet] Note: there were 662 duplicate class definitions. [2014-07-15 23:57:43 - MozMeet] Warning: com.parse.FacebookAuthenticationProvider$1:…
An SO User
  • 24,612
  • 35
  • 133
  • 221
36
votes
2 answers

How to use -dontwarn in ProGuard?

I am using android studio to build debug and release application. When i build debug/release application ./gradlew assembleDebug ./gradlew assembleRelease both build are created perfectly and run as well. Shows appropriate dialog box for debug or…
morya
  • 835
  • 2
  • 10
  • 19
36
votes
2 answers

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum

I've just built an APK using Gradle for release (ProGuard 4.9 and signed). When I launch the app it crash on this error : E/AndroidRuntime( 8662): java.lang.AssertionError: impossible E/AndroidRuntime( 8662): at…
ebtokyo
  • 2,369
  • 4
  • 23
  • 33
36
votes
2 answers

Keep annotated class in Proguard

I have a bunch of classes that use e.g. an @Singleton annotation like so @Singleton public class ImageCache that I would like to keep. How can I configure a proguard -keep statement so it applies to all classes that have that annotation. Btw in…
Manfred Moser
  • 29,539
  • 13
  • 92
  • 123