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

隐身守侯 提交于 2019-12-10 01:10:00

问题


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'
        }
    }

回答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.




回答2:


Delete folder build inside app folder, then regenerate.




回答3:


You can try delete folder build inside app folder.

Then regenerate.




回答4:


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!



来源:https://stackoverflow.com/questions/28258449/cant-generate-signed-apk-in-android-studio-because-proguard-rules-txt-is-missi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!