31

It used to be that proguard was controlled by project.properties, but that's no longer the case, and the Android documentation has not been updated. The project.properties file now clearly states that the it is generated by Android Tools and changes will be erased. I've tried commenting out the proguard.config line, but when I compile, it rewrites the project.properties, and continues to use proguard. What is the current method of disabling proguard? Thanks!

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# 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:proguard-google-api-client.txt

# Project target.
target=android-17
android.library.reference.1=../../../../android-sdk-linux/extras/google/google_play_services/libproject/google-play-services_lib
piusvelte
  • 1,596
  • 2
  • 15
  • 18
  • 2
    Did you try to delete the directory with the mappings which are created by proguard? – rekire Feb 22 '13 at 19:05
  • 1
    Do you have the latest SDK? When I generate a new project and look at my `project.properties` the ProGuard line is commented out by default and the comment above it says to *un*comment it to enable ProGuard... – kabuko Feb 22 '13 at 19:17
  • @rekire good call, thank you! I deleted the proguard dir under my project, and commented out the proguard.config line again and have successfully disabled proguard. Thank you! – piusvelte Feb 22 '13 at 19:28
  • @piusvelte if his answered helped you - mark it as accepted – nikib3ro Feb 22 '13 at 20:25
  • 1
    @kape123 I didn't see an option to accept a comment as the answer. I see that he's now added and answer, which I've accepted. Thank you! – piusvelte Feb 22 '13 at 20:39

6 Answers6

37

set this

minifyEnabled false

in your app build.gradle

Like this:

 buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false 
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
ahmadalibaloch
  • 5,851
  • 2
  • 50
  • 59
28

set

 useProguard false

in your app build.gradle

like

  buildTypes {
    release {
        minifyEnabled false
        useProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
Alex
  • 716
  • 8
  • 9
  • Best answer! Should be the definitive! – Bruno Carneiro Apr 17 '20 at 14:27
  • 8
    as of 2020/06 -> The setting "useProguard" is being deprecated, and will be removed in Android Studio 3.5, see issue https://issuetracker.google.com/issues/129758703 – Sam Jun 17 '20 at 00:54
12

Have you tried to add the next line to your proguard configuration file (to the beginning of the file) :

-dontobfuscate

?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
9

Try to delete the proguard directory in your project. So proguard will forget its mapping.

rekire
  • 47,260
  • 30
  • 167
  • 264
0

According to the React-Native Docs, To disable Proguard, set def enableProguardInReleaseBuilds to false in your android/app/build.gradle:

/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false // Instead of true
Car4p17
  • 45
  • 1
  • 6
0

In my case 1 -> add this line in the android tag:

 android {
    def enableProguardInReleaseBuilds = false // Instead of true

2 -> then add this line

    buildTypes {
    release {
        minifyEnabled false
        shrinkResources = false
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

I hope it will work for you

M Azam Khan
  • 302
  • 3
  • 15