25

In my demo project, proguard-rules.txt is not available in Android studio.

I must be missing some code :

enter image description here

Where can I find proguard-rules.txt file?

I want to add proguard rules

Any help is appriciated

Thank you

Kushal
  • 8,100
  • 9
  • 63
  • 82

4 Answers4

18

Looks like your project is missing proguard files. You can add it yourself: put the proguard-rules.txt file into the app directory. It's already added to your build.gradle file so no further actions required.

aga
  • 27,954
  • 13
  • 86
  • 121
  • 4
    Android Studio older version do not include `proguard-rules.pro` automatically, so manually adding it works...Thank you !! – Kushal Jul 29 '15 at 13:14
9

proguard-rules.txt (or proguard-android.txt) are in your SDK folder, but if you want to add something to your ProGuard rules you should do this in proguard-rules.pro.

This file should be automatically added to your project by Android Studio when you create new (if isn't present - create manually). Check DOC (Gradle section ofc)

snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • As you mentioned, I changed the line to `proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'` but still **proguard-rules.pro** is not added in Android studio project – Kushal Jul 29 '15 at 09:48
6

it is located under your sdk folder, usually in yoursdk/tools/proguard/. If you are using linux or mac, once you cd into the sdk folder you can run

find . -iname proguard-rules.txt

to look for it

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • 1
    I found the path.. I changed code to `proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'` but still Android studio project do not have **proguard-rules.pro** file for my project.. Where should I write proguard rules related to my project? – Kushal Jul 29 '15 at 09:49
  • we keep it on the root of our project. – Blackbelt Jul 29 '15 at 09:56
2

You can manually create the file in the \StudioProjects\your_project\app folder and you can add the custom rules.

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108
Vikas
  • 4,263
  • 1
  • 34
  • 39