Skip to content

Commit 7453e3a

Browse files
committed
Add ProGuard sample
1 parent 67fce8f commit 7453e3a

2 files changed

Lines changed: 84 additions & 1 deletion

File tree

demo/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,11 @@ compose.desktop {
3232
packageName = "tray-demo"
3333
packageVersion = "1.0.0"
3434
}
35+
buildTypes.release.proguard {
36+
isEnabled = true
37+
obfuscate.set(false)
38+
optimize.set(true)
39+
configurationFiles.from(project.file("proguard-rules.pro"))
40+
}
3541
}
36-
}
42+
}

demo/proguard-rules.pro

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
-keepclasseswithmembers public class com.kdroid.composetray.demo.DynamicTrayMenuKt { #
2+
public static void main(java.lang.String[]);
3+
}
4+
5+
-dontwarn kotlinx.coroutines.debug.*
6+
7+
-keep class kotlin.** { *; }
8+
-keep class kotlinx.** { *; }
9+
-keep class kotlinx.coroutines.** { *; }
10+
-keep class org.jetbrains.skia.** { *; }
11+
-keep class org.jetbrains.skiko.** { *; }
12+
-keep class com.sun.jna.** { *; }
13+
-keep class * implements com.sun.jna.** { *; }
14+
-keepclassmembers class * extends com.sun.jna.* { public *; }
15+
-keepclassmembers class * implements com.sun.jna.* { public *; }
16+
-dontwarn com.sun.jna.**
17+
18+
# Keep specific JNA Platform classes used in the project
19+
-keep class com.sun.jna.platform.** { *; }
20+
-keep class com.sun.jna.win32.** { *; }
21+
-dontwarn com.sun.jna.platform.**
22+
23+
24+
-keep class com.kdroid.composetray.** { *; }
25+
26+
-assumenosideeffects public class androidx.compose.runtime.ComposerKt {
27+
void sourceInformation(androidx.compose.runtime.Composer,java.lang.String);
28+
void sourceInformationMarkerStart(androidx.compose.runtime.Composer,int,java.lang.String);
29+
void sourceInformationMarkerEnd(androidx.compose.runtime.Composer);
30+
}
31+
32+
# Keep `Companion` object fields of serializable classes.
33+
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
34+
-if @kotlinx.serialization.Serializable class **
35+
-keepclassmembers class <1> {
36+
static <1>$Companion Companion;
37+
}
38+
39+
# Keep `serializer()` on companion objects (both default and named) of serializable classes.
40+
-if @kotlinx.serialization.Serializable class ** {
41+
static **$* *;
42+
}
43+
-keepclassmembers class <2>$<3> {
44+
kotlinx.serialization.KSerializer serializer(...);
45+
}
46+
47+
# Keep `INSTANCE.serializer()` of serializable objects.
48+
-if @kotlinx.serialization.Serializable class ** {
49+
public static ** INSTANCE;
50+
}
51+
-keepclassmembers class <1> {
52+
public static <1> INSTANCE;
53+
kotlinx.serialization.KSerializer serializer(...);
54+
}
55+
56+
# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
57+
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
58+
59+
-keepattributes *Annotation*, InnerClasses
60+
-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
61+
-dontnote kotlinx.serialization.SerializationKt
62+
63+
64+
# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
65+
-dontwarn okhttp3.internal.platform.**
66+
-dontwarn org.conscrypt.**
67+
-dontwarn org.bouncycastle.**
68+
-dontwarn org.openjsse.**
69+
#################################### SLF4J #####################################
70+
-dontwarn org.slf4j.**
71+
72+
# Prevent runtime crashes from use of class.java.getName()
73+
-dontwarn javax.naming.**
74+
75+
# Ignore warnings and Don't obfuscate for now
76+
-dontobfuscate
77+
-ignorewarnings

0 commit comments

Comments
 (0)