proguard-project.txt not found in android studio

39,096

Solution 1

Use the proguard-rules.txt file instead. Proguard doesn't attach any special significance to the name of its rule input files; it uses whatever's set up in your build files, which for new projects created in recent versions of Android Studio, is:

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

The proguard-android.txt file lives inside your SDK, and contains reasonable Android-wide defaults that all projects should use.

Solution 2

I had the same problem when I started using Android Studio

You can't see the ProGuard files because you are previewing you project in a non Project file mode. Which most probably will be Android view mode.

enter image description here

You have to change the mode by clicking on the drop down list of the Android selection and select Project Files to see all the files in the project as the following:

enter image description here

Then you will be able to see the hidden files in the Android project structure view mode.

enter image description here

And here is a good example for the ProGuard

Solution 3

You can find proguard-project.txt in

C:\Users\"USER"\AppData\Local\Android\android-studio\sdk\tools\proguard

"USER" is the name in you will see when you click on c-drive \users \yourname

Solution 4

the code posted previously must be corrected to the following according to your use:

buildTypes {
     release {
         minifyEnabled true  //according to your use
         // or
         minifyEnabled false //according to your use
         // runProguard false ** NOT USED ANYMORE, replaced by minifyEnabled
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
     }
 }

Solution 5

I couldn't find this proguard-rules.txt anywhere on my Windows machine with Android Studio. I did however find a LayoutExample\app\proguard-rules.pro file. This is probably because I had imported my project from Eclipse, so Android Studio didn't create one automatically. So what I did was:

1 - Copy the proguard-rules.pro from the example project to the same folder as build.gradle for my project (you can either search for this file on your machine or create an empty project)

2 - Edit the code in build.gradle to use this file instead of proguard-rules.txt, e.g.

    buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
}
  1. Sync gradle, then Build > Build APK. Worked fine for me.
Share:
39,096
MCA Shah
Author by

MCA Shah

Updated on March 06, 2020

Comments

  • MCA Shah
    MCA Shah about 4 years

    I am new to Android and Android Studio.

    During my learning I came across the Google Play Services for Ads and all.

    I tried to enable proguard in my project but reading the below link proguard.

    The problem is that I am not able to find proguard-project.txt or proguard.cfg in my project structure...

    Instead there is a proguard-rules.txt in my project structure...

    How can I find these missing files and configure proguard in my project...

    Please help...