Collection of modern Android Proguard files.
Based on the Proguard Snippets by @krschultz.
Separation of Concerns MATTERS!
Instead of having one giant proguard.pro file for an app, you can split it out based off of the dependencies that it is tied to.
- Only Update/Replace in the corresponding proguard file for a given capability
- Share proguard configuration files easily across apps and modules (if needed)
- Remove proguard files when you remove libraries
- IT RESULTS IN READABLE PROGUARD FILES! 🙀
Easy inline functions make Kotlin-Gradle pretty great
- Place
*.profiles in the following folderandroid-app/app/proguard(for most folks) - Place the following bit of code in your
buildSrc(reusable) orbuild.gradle.ktsdirectly for a simple filter
class ProguardFilter : FilenameFilter {
override fun accept(
f: File,
filename: String
): Boolean {
return filename.endsWith("pro") || filename.endsWith("txt")
}
}- Add the following function to
build.gradle.ktsin yourappmodule (or other applicable module) under theandroid{}section
android {
....
val proGuardFolderCollection =
files(
file("./proguard")
.listFiles(ProguardFilter())
)
.toList()
.toTypedArray()
}- Apply your
proguardcollection in yourbuild.gradle.ktsin yourappmodule under thebuildTypes{}section
buildTypes{
getByName("release") {
proguardFiles(*proGuardFolderCollection)
}
}(Copied from Proguard Snippets by @krschultz with some additions)
- Place
*.profiles in the following folderandroid-app/app/proguard(for most folks) - Place the following bit of code in your
appmodule (or function classes for building)build.gradlefor a file filter
class ProguardFilter implements FilenameFilter {
public boolean accept(File f, String filename) {
return filename.endsWith("pro") || filename.endsWith("txt")
}
}- Add the following function to
build.gradlein yourappmodule (or other applicable module) under theandroid{}section
android{
....
FileCollection proGuardFileCollection = files { file('./proguard').listFiles(ProguardFilter()) }
}- Apply your
proguardcollection in yourbuild.gradle.ktsin yourappmodule under thebuildTypes{}section
buildTypes{
release {
proguardFiles(proGuardFileCollection)
}
}