13

I have a problem with generating signed APK in Android Studio. After fixing all the warnings I am stuck on this one:

Error:Execution failed for task ':app:proguardRelease'. java.io.FileNotFoundException: /Users/franek/Documents/Android_Studio_Melange/app/proguard-rules.txt (No such file or directory)

I don't want to change minifyEnabled to false, because I want to keep Proguard working. How can I fix this error?

A fragment of build.gradle:

buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
fragon
  • 3,391
  • 10
  • 39
  • 76

5 Answers5

31
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt')
    }
}

should work ok, as long as you don't need any special ProGuard configuration. If you do, use your original proguardFiles entry and create the file

/Users/franek/Documents/Android_Studio_Melange/app/proguard-rules.txt

Then put your custom rules in this file.

stkent
  • 19,772
  • 14
  • 85
  • 111
6

Delete folder build inside app folder, then regenerate.

Aref Bahreini
  • 774
  • 8
  • 14
2

You can try delete folder build inside app folder.enter image description here

Then regenerate.

enter image description here

Vladimir Salguero
  • 5,609
  • 3
  • 42
  • 47
0

you need to disable the proguard

you can follow these steps: (to disable the proguard)

https://stackoverflow.com/a/72272882/10340870

it works for me. After disable the pro guards I'm able to generate the signed aab file

M Azam Khan
  • 302
  • 3
  • 15
-2

I realise this question has been long answered, but I had the same problem and have been trying for hours to fix it. None of the solutions on here worked for me, so I'm adding this to save others the trouble.

I solved the issue just by completely getting rid of the proguardFiles line, so my code looks like:

buildTypes {
    release {
        minifyEnabled true
    }
}

Of course this doesn't help if you need a specific proguard file, but I thought I had to specify one and it turned out I didn't. I hope this helps!

Luke Needham
  • 3,373
  • 1
  • 24
  • 41
  • 1
    This seems like it might be dangerous, since the default ProGuard files protect a bunch of Android platform stuff from obfuscation: see e.g. https://android.googlesource.com/platform/sdk/+/7dd444ea0125e50a5e88604afb6de43e80b7c270/files/proguard-android.txt You can guess what might break by looking at the classes in this list. – stkent Apr 01 '16 at 17:50
  • My app runs fine after exporting through this proguard configuration, and does properly obfuscate the code, although you are probably correct. However since I couldn't get it to work any other way, this is the only option I could find. – Luke Needham Apr 21 '16 at 01:24