Can't generate signed APK in Android Studio, because proguard-rules.txt is missing

14,102

Solution 1

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.

Solution 2

Delete folder build inside app folder, then regenerate.

Solution 3

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

Then regenerate.

enter image description here

Share:
14,102
fragon
Author by

fragon

Updated on June 05, 2022

Comments

  • fragon
    fragon almost 2 years

    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'
            }
        }
    
  • stkent
    stkent about 8 years
    This seems like it might be dangerous, since the default ProGuard files protect a bunch of Android platform stuff from obfuscation: see e.g. android.googlesource.com/platform/sdk/+/… You can guess what might break by looking at the classes in this list.
  • Luke Needham
    Luke Needham about 8 years
    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.
  • Leap Bun
    Leap Bun about 7 years
    This helps me. Thanks.