ProGuard rule for the Android Library

  • ProGuard rule for the Microsoft Authentication Library 
Here's an example of ProGuard rule for the com.microsoft.identity.client:msal:** library:
-keep class com.microsoft.identity.** { *; }
-keep class com.microsoft.aad.** { *; }
-keep class com.microsoft.authenticator.** { *; }
-keep class com.microsoft.identity.common.** { *; }
-keep class com.microsoft.identity.client.** { *; }
-keep class com.microsoft.identity.internal.** { *; }

-keep class javax.crypto.** { *; }
-keep class org.json.** { *; }
-keep class androidx.localbroadcastmanager.** { *; }

-keep class okhttp3.** { *; }
-dontwarn okhttp3.**

-keep class retrofit2.** { *; }
-dontwarn retrofit2.**

-keep class retrofit2.converter.gson.** { *; }
-keepattributes *Annotation*
-dontwarn javax.annotation.**
-dontwarn retrofit2.converter.gson.**

-keepattributes Signature

-keepclassmembers class * {
    @com.google.gson.annotations.SerializedName <fields>;
}

-keepclasseswithmembers class * {
    @com.microsoft.identity.common.adal.internal.AuthenticationConstants$ClaimChallenge **;
}

  • ProGuard rule for the Firebase Analytics

# Firebase Analytics
-keep class com.google.android.gms.internal.measurement.** { *; }
-keep class com.google.android.gms.common.internal.service.Common$Api.* { *; }
-keep class com.google.android.gms.common.api.internal.OptionalPendingResultImpl { *; }
-keep class com.google.android.gms.common.api.Status { *; }
-keep class com.google.firebase.analytics.FirebaseAnalytics { *; }
-keep class com.google.firebase.analytics.FirebaseAnalytics$Event { *; }
-keep class com.google.firebase.analytics.FirebaseAnalytics$Param { *; } 
  • ProGuard rule for the Firebase Messaging
-keep class com.google.firebase.messaging.** { *; }
-keep class com.google.android.gms.common.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
-keep class com.google.firebase.iid.** { *; }
-keep class com.google.firebase.installations.** { *; }

# Required for firebase-messaging:19.0.0 and up
-dontwarn com.google.android.gms.common.internal.Constants

# Optional for improved performance
-optimizations !method/inlining/*

# For debugging purpose, you can use
# -printconfiguration config.txt
# to dump the resulting configuration in config.txt

Explanation: 

  1. -keep is used to keep specific classes and their members from being removed or obfuscated by ProGuard.
  2. The first five -keep rules are recommended by Firebase and should be included to prevent issues with the Firebase Messaging library.
  3. -dontwarn com.google.android.gms.common.internal.Constants prevents ProGuard from warning about the removal of this class, which is no longer used in recent versions of Firebase Messaging.
  4. -optimizations !method/inlining/* disables inlining of methods, which can sometimes cause issues with third-party libraries.
  5. The last line is optional and can be used to dump the resulting configuration in a file for debugging purposes.

  • ProGuard rule for the Firebase Crashlytics
# Firebase Crashlytics
-keepattributes *Annotation*
-keep class com.google.firebase.crashlytics.** { *; }
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

These rules will keep all classes and methods related to Firebase Crashlytics and Crashlytics. They will also keep the source file and line number information, as well as any public class that extends java.lang.Exception. 





கருத்துரையிடுக

Post a Comment (0)

புதியது பழையவை