Skip to content

Commit 8fca17e

Browse files
committed
add docs to proguard
1 parent 17f7ff9 commit 8fca17e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

  • Sources/SwiftJavaDocumentation/Documentation.docc

Sources/SwiftJavaDocumentation/Documentation.docc/Android.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
# Android
1+
# Android
2+
3+
## R8/Proguard Rules
4+
5+
Since swift-java uses JNI and reflection APIs, we must tell the R8 optimizer to ignore our wrapped our types,
6+
otherwise we will into runtime crashes, because types are stripped from the APK/AAR.
7+
8+
The `SwiftKit` Java library already contains a [Proguard consumer file](https://developer.anbdroid.com/topic/performance/app-optimization/library-optimization),
9+
which is automatically detected by R8, so any `org.swift.swiftkit` types are already ignored.
10+
However, you must still provide rules for your own types.
11+
12+
For example, if your library is named is `org.swift.exampleapp`, then add the following rules to your proguard file:
13+
14+
```
15+
-keep class org.swift.exampleapp.** { *; }
16+
-keep interface org.swift.exampleapp.** { *; }
17+
```
218

319
## Android Core Library Desugaring
420

0 commit comments

Comments
 (0)