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
53
votes
8 answers

Proguard issue "Warning:Ignoring InnerClasses attribute for an anonymous inner class"

I don't know how I can describe this issue. I searched a lot, but I didn't find any solution. Also this solution did not help me -keepattributes EnclosingMethod: dependencies { compile project(':libraries:material-drawer') compile…
53
votes
5 answers

ProGuard for Android and GSON

I'm setting up ProGuard for my Android project. My project also uses GSON. I've researched ProGuard configurations for compatibility with GSON and Android and came across this example offered by google-gson…
AtariPete
  • 1,368
  • 6
  • 19
  • 29
51
votes
2 answers

Getting Warnings With Proguard (With External Libraries)

I have enabled Proguard, and i'm trying to build the APK, and i'm getting a lot of warnings and don't know how to solve them . I'm using Retrofit, Jsoup and other stock libraries, I'm getting the following warnings : Warning:okio.DeflaterSink:…
Jaeger
  • 1,646
  • 8
  • 27
  • 59
51
votes
4 answers

Gradle failed to build when proguard is activated

I am trying to release my Android application with Gradle. Everything works, including the ./gradlew clean build assembleRelease command. However, as soon as I try to use proguard, Gradle fail to build the release version. Here is the error I get…
pommedeterresautee
  • 1,843
  • 1
  • 20
  • 24
50
votes
3 answers

What is the difference between proguard-android.txt and proguard-rules.pro ? - Android

In my buildType I see this: buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } I have some questions: Why there are two files?…
MBH
  • 16,271
  • 19
  • 99
  • 149
49
votes
4 answers

Compile with Proguard gives SimException: "local variable type mismatch"

When I compile my Android Application with Proguard enabled I get the following error: -dex: [echo] Converting compiled files and external libraries into /home/ka/dev/workspace/ImPress/build/classes.dex... [apply] [apply] UNEXPECTED TOP-LEVEL…
Catalin Morosan
  • 7,897
  • 11
  • 53
  • 73
49
votes
5 answers

How to use Kotlin with Proguard

I'm trying to add Kotlin to my project and I need to use proguard. Which rules should I add to proguard to support Kotlin? Thank you
Fábio Carballo
  • 3,245
  • 5
  • 26
  • 36
49
votes
4 answers

Does proguard work to obfuscate static string constants?

Will proguard work to obfuscate static string constants?
Code Droid
  • 10,344
  • 17
  • 72
  • 112
47
votes
2 answers

What is the difference between consumer-rules.pro and proguard-rules.pro in Android?

I have create a module in Android to use in my main app and there seem to be two of these files consumer-rules.pro and proguard-rules.pro. I would like to know the folllowing things Will all of the modules code be obfuscated by the rules of the…
Dishonered
  • 8,449
  • 9
  • 37
  • 50
46
votes
11 answers

android studio 3.1 Warning: The rule `-keep public class *extends java.lang.annotation.Annotation {

i recently upgraded android studio but im not able to find the source of the following issue reported in android studio 3.1: Warning: The rule `-keep public class *extends java.lang.annotation.Annotation { the warning seems to be cut off perhaps…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
45
votes
3 answers

Removing Log call using proguard

I am trying to use proguard to strip all my logs: I have entered the following line in my proguard-project.txt: -assumenosideeffects class android.util.Log { *; } And my project.properties looks like…
user1667307
  • 2,041
  • 6
  • 27
  • 32
44
votes
1 answer

How do you stop Proguard from removing type parameters?

I am currently attempting to obfuscate a series of libraries. My base library, which contains several classes and methods that use type parameters, is unusable by other code due to the type parameters being removed by Proguard obfuscation.…
Nick Johnson
  • 1,392
  • 1
  • 10
  • 14
42
votes
2 answers

Using Proguard with Android without obfuscation

I am getting an error "Conversion to Dalvik format failed with error 1" when using the -dontobfuscate flag. Otherwise my app exports fine. I don't want to obfuscate because I am using BugSense for error tracking and they charge $99 a month if you…
theJosh
  • 2,894
  • 1
  • 28
  • 50
41
votes
4 answers

Proguard - do not obfuscate Kotlin data classes

In my project I use AutoValue for my old model classes. I started using Kotlin and I want to use Data Classes instead of AutoValue. I want to disable the obfuscation for all Data classes in my Data layer but to keep obfuscating the other classes in…
Mario Kutlev
  • 4,897
  • 7
  • 44
  • 62
41
votes
4 answers

Proguard keep class names?

Hello I am writing an Android app and I have set up Proguard to obfuscate my application. I however use a classloader to dynamically load different extensions to my application. The problem is that these don't load correctly if their names are…
Nik
  • 1,033
  • 2
  • 11
  • 28