1- # Add project specific ProGuard rules here.
2- # You can control the set of applied configuration files using the
3- # proguardFiles setting in build.gradle.
4- #
5- # For more details, see
6- # http://developer.android.com/guide/developing/tools/proguard.html
7-
8- # If your project uses WebView with JS, uncomment the following
9- # and specify the fully qualified class name to the JavaScript interface
10- # class:
11- #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12- # public *;
13- #}
14-
15- # Uncomment this to preserve the line number information for
16- # debugging stack traces.
17- #-keepattributes SourceFile,LineNumberTable
18-
19- # If you keep the line number information, uncomment this to
20- # hide the original source file name.
21- #-renamesourcefileattribute SourceFile
1+ # General Android rules often recommended
2+ -dontobfuscate # If you don’t want obfuscation during development/testing phase of release,
3+ # but for the final release to Play Market, it's better to enable it (comment out this line)
4+ # When enabled, class, method, and field names are changed to short ones (a, b, c),
5+ # which complicates reverse engineering, but also makes crash reports harder to analyze.
6+ # If you keep -dontobfuscate, then isMinifyEnabled = true will mostly perform shrinking (code removal).
7+
8+ -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* # Example of disabling aggressive optimizations if they cause issues
9+
10+ -keepattributes Signature # Keeps generic types for reflection
11+ -keepattributes InnerClasses # Keeps info about inner and anonymous classes
12+ -keepattributes *Annotation* # Keeps annotations (important for Hilt, Room, Kotlinx Serialization, Retrofit)
13+
14+ # --- Kotlin Standard Library and Coroutines ---
15+ -dontwarn kotlin.**
16+ -keep class kotlin.Metadata { *; } # Needed for Kotlin reflection
17+ -keepclassmembers class kotlin.coroutines.jvm.internal.BaseContinuationImpl {
18+ <fields>;
19+ <init>(...); # Keep constructors
20+ }
21+ -keep class kotlin.coroutines.jvm.internal.DebugProbesKt { *; }
22+ -keepclassmembers class kotlin.Result { *; } # Keep Result class
23+ -keepclassmembers class kotlin.DeepRecursiveScope { *; } # For deep recursion
24+ -keepclassmembers class kotlin.DeepRecursiveFunction { *; }
25+
26+ # For kotlinx.coroutines
27+ -keepnames class kotlinx.coroutines.internal.MainDispatcherFactory { *; }
28+ -keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory { *; }
29+ -keepnames class kotlinx.coroutines.CoroutineExceptionHandler { *; }
30+
31+ # --- Kotlinx Serialization ---
32+ # These rules are critical if you're using Kotlinx Serialization
33+ -keepclassmembers class kotlinx.serialization.internal.* {
34+ *;
35+ }
36+ -keep class **$$serializer { *; } # Keeps generated serializers
37+ -keepnames class * implements kotlinx.serialization.KSerializer
38+ -keepnames class * { @kotlinx.serialization.Serializable <fields>; } # Keeps fields of classes annotated with @Serializable
39+ -if class ** { @kotlinx.serialization.Serializable *; } -keep class <1>$$serializer { *; }
40+
41+ # For enum classes annotated with @Serializable
42+ -keepclassmembers enum * {
43+ @kotlinx.serialization.SerialName <fields>;
44+ <methods>; # Keep methods, including values() and valueOf()
45+ }
46+
47+ # --- Retrofit & OkHttp ---
48+ # If your DTOs (Data Transfer Objects) are properly annotated with @Serializable,
49+ # the rules for Kotlinx Serialization above should cover them.
50+ # If not, or if you're using other converters (like Gson), other rules are needed.
51+
52+ # Keep DTOs if not covered by serialization rules
53+ -keep class com.artemzarubin.weatherml.data.remote.dto.** { *; }
54+ -keep interface com.artemzarubin.weatherml.data.remote.dto.** { *; }
55+
56+ # For Retrofit (usually not much is needed if DTOs are kept)
57+ -dontwarn retrofit2.**
58+ -keep class retrofit2.** { *; }
59+ -keep interface retrofit2.** { *; }
60+ -keepattributes Exceptions # For Retrofit methods that throw exceptions
61+
62+ # For OkHttp (usually not needed unless using reflection with it)
63+ -dontwarn okhttp3.**
64+ -dontwarn okio.**
65+
66+ # --- Hilt (Dependency Injection) ---
67+ # Hilt usually auto-generates the needed rules. These are backup or for resolving issues.
68+ -keep class dagger.hilt.android.internal.** { *; }
69+ -keep class * extends dagger.hilt.android.internal.managers.ActivityRetainedComponentManager$LifecycleModule { *; }
70+ -keep class * implements dagger.hilt.internal.GeneratedComponent { *; }
71+ -keep class * implements dagger.hilt.internal.GeneratedEntryPoint { *; }
72+ -keep @dagger.hilt.android.HiltAndroidApp class * { <init>(); }
73+ -keep @dagger.hilt.android.AndroidEntryPoint class * { <init>(); }
74+ -keep @dagger.hilt.android.lifecycle.HiltViewModel class * { <init>(...); } # Keep ViewModel constructors
75+ -keepclassmembers class * { @javax.inject.Inject <init>(...); } # Keep constructors annotated with @Inject
76+ -keepclassmembers class * { @dagger.hilt.android.AndroidEntryPoint *; }
77+ -keepclassmembers class * { @dagger.hilt.android.lifecycle.HiltViewModel *; }
78+ -keepclassmembers @dagger.Module class * { <methods>; } # Keep methods in Hilt modules
79+ -keepclassmembers @dagger.Provides class * { <methods>; } # Keep methods annotated with @Provides
80+ -keepclassmembers @dagger.Binds class * { <methods>; } # Keep methods annotated with @Binds
81+
82+ # --- Room Persistence Library ---
83+ # KSP for Room generates code that usually doesn’t need special ProGuard rules,
84+ # unless you use reflection with Entity or Dao.
85+ # But for backup you can add:
86+ -keep class androidx.room.** { *; }
87+ -keep class com.artemzarubin.weatherml.data.local.** { *; } # Keep your Entity, Dao, Database
88+ -keep interface com.artemzarubin.weatherml.data.local.** { *; }
89+
90+ # --- Jetpack Compose ---
91+ # Compose rules are usually included by the Android Gradle Plugin automatically.
92+ # If you encounter issues related to Compose in release builds,
93+ # you might need to add specific rules, but it’s rare.
94+ # -keepclassmembers class * { @androidx.compose.runtime.Composable <methods>; }
95+ # -keepclassmembers class * { @androidx.compose.runtime.Composable <fields>; }
96+
97+ # --- TensorFlow Lite ---
98+ # If you just load a .tflite file and use the standard Interpreter,
99+ # special rules are usually not required.
100+ # If you use the TensorFlow Lite Support Library for specific models or pre/post-processing,
101+ # rules might be required to keep those classes.
102+ # -keep class org.tensorflow.lite.support.** { *; } # Example if using Support Library
103+
104+ # --- Your own data/model classes that may be used for serialization or reflection ---
105+ # If your domain models are not annotated with @Serializable and not used directly by Retrofit/Room,
106+ # but are serialized or reflected otherwise, you also need to keep them.
107+ -keep class com.artemzarubin.weatherml.domain.model.** { *; }
108+ -keep interface com.artemzarubin.weatherml.domain.model.** { *; }
109+
110+ # --- Rules for AndroidX Core, Lifecycle, Activity (usually not needed but for safety) ---
111+ -keep class androidx.core.** { *; }
112+ -keep class androidx.lifecycle.** { *; }
113+ -keep class androidx.activity.** { *; }
114+
115+ # --- Rules for Google Play Services Location (FusedLocationProviderClient) ---
116+ # Usually doesn’t need special rules if used in standard way.
117+ -keep class com.google.android.gms.location.** { *; }
118+
119+ # --- DataStore Preferences ---
120+ # If you use standard keys and types, special rules are usually not needed.
121+ # If you use custom serializers for DataStore, you need to keep them.
122+ -keep class androidx.datastore.preferences.core.** { *; }
123+
124+ # --- Don’t forget to add rules for any other libraries you use ---
125+ # --- especially if they use reflection or you see crashes in release builds ---
126+
127+ # Example of ignoring warnings for certain libraries (use with caution):
128+ # -dontwarn com.example.somelibrary.**
0 commit comments