Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'
        }
    }
like image 402
fragon Avatar asked Feb 01 '15 01:02

fragon


People also ask

Where can I find ProGuard-Android TXT?

The getDefaultProguardFile('proguard-android. txt') method obtains the default ProGuard settings from the Android SDK tools/proguard/ folder. The proguard-android-optimize. txt file is also available in this Android SDK folder with the same rules but with optimizations enabled.

How do you add ProGuard rules?

When you create a new project or module using Android Studio, the IDE creates a <module-dir>/proguard-rules.pro file for you to include your own rules. You can also include additional rules from other files by adding them to the proguardFiles property in your module's build. gradle file.

Where is ProGuard rules file?

Android Gradle Plugin provides us two different ProGuard rules config files which are located under build/intermediates/proguard-files .


1 Answers

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.

like image 141
stkent Avatar answered Sep 22 '22 22:09

stkent