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
*.pro
files in the following folderandroid-app/app/proguard
(for most folks) - Place the following bit of code in your
buildSrc
(reusable) orbuild.gradle.kts
directly 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.kts
in yourapp
module (or other applicable module) under theandroid{}
section
android {
....
val proGuardFolderCollection =
files(
file("./proguard")
.listFiles(ProguardFilter())
)
.toList()
.toTypedArray()
}
- Apply your
proguard
collection in yourbuild.gradle.kts
in yourapp
module under thebuildTypes{}
section
buildTypes{
getByName("release") {
proguardFiles(*proGuardFolderCollection)
}
}
(Copied from Proguard Snippets by @krschultz with some additions)
- Place
*.pro
files in the following folderandroid-app/app/proguard
(for most folks) - Place the following bit of code in your
app
module (or function classes for building)build.gradle
for 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.gradle
in yourapp
module (or other applicable module) under theandroid{}
section
android{
....
FileCollection proGuardFileCollection = files { file('./proguard').listFiles(ProguardFilter()) }
}
- Apply your
proguard
collection in yourbuild.gradle.kts
in yourapp
module under thebuildTypes{}
section
buildTypes{
release {
proguardFiles(proGuardFileCollection)
}
}