Skip to content

Commit 0e84c33

Browse files
authored
Bundle proguard rules for Android (#834)
Refs https://square.github.io/okhttp/features/r8_proguard/.
1 parent d35bd20 commit 0e84c33

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project orients towards [Semantic Versioning](http://semver.org/spec/v2
77
Note: This project needs KSP to work and every new Ktorfit with an update of the KSP version is technically a breaking change.
88
But there is no intent to bump the Ktorfit major version for every KSP update.
99

10+
11+
# [Unreleased]()
12+
13+
Unreleased - 2025-xx-xx
14+
========================================
15+
16+
## Added
17+
- Bundle proguard rules for Android
18+
19+
1020
# [2.4.1]()
1121

1222
2.4.1 - 2025-03-14

docs/android/proguard.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
proguard-rules.pro
2-
```
3-
-keep class de.jensklingenberg.ktorfit.** { *; }
4-
-keepclassmembers class de.jensklingenberg.ktorfit.** { *; }
5-
```
1+
If you use Ktorfit as a dependency in an Android project which uses R8 as a default compiler you don’t have to
2+
do anything. The specific rules are
3+
[already bundled](../../ktorfit-lib-core/src/jvmMain/resources/META-INF/proguard/ktorfit.pro) into the JAR
4+
which can be interpreted by R8 automatically.

ktorfit-lib-core/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ android {
173173
defaultConfig {
174174
minSdk = 21
175175
targetSdk = 34
176+
177+
val proguardFile =
178+
file("src/jvmMain/resources/META-INF/proguard/ktorfit.pro").also {
179+
if (!it.exists()) {
180+
throw NoSuchFileException(
181+
file = it,
182+
reason = "We have to provide a proguard rules file for the library.",
183+
)
184+
}
185+
}
186+
consumerProguardFiles(proguardFile)
176187
}
177188
namespace = "de.jensklingenberg.ktorfit.common"
178189
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-keep class de.jensklingenberg.ktorfit.** { *; }
2+
-keepclassmembers class de.jensklingenberg.ktorfit.** { *; }

0 commit comments

Comments
 (0)