microsoft-authentication-library-for-android: Proguard not supported by default

When using proguard + msal, the following rules are required to make the client work:

# This enum is accessed via reflection in common msal lib thus proguard removes it.
-keep public enum  {

# Classes for below package is used by MSAL library. Ignore warning coming from the dependency.
-dontwarn com.nimbusds.jose.**

This rules can be packaged directly in the msal library and common library instead of asking developers to do so.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15 (9 by maintainers)

Most upvoted comments

I have an issue with Proguard too when using MSAL v1.0.0:

java.lang.AssertionError: AssertionError (GSON 2.8.5): java.lang.NoSuchFieldException: DEFAULT
        at e.d.d.q.a(
        at e.d.d.q.a(
        at e.d.d.q.a(
        at e.d.d.q.a(

UPDATE : This issue was fixed when I added the configuration file provided by the link in the previous post and the following lines:

-keep public enum { *; }
-keep public class { *; }
-keep public class { *; }

This is what came up when fixing the rules when used in AppCenter:

This covers basic AAD B2C scenarios but you might want to apply that keep rules to every model or enum used via Gson.

We can already do it in proguard, the Microsoft AppCenter SDK uses this already.

Just needs

android {

        defaultConfig {
            consumerProguardFiles ''

In the build.gradle for the library.

It will be automatically added by android gradle plugin as proguard.txt in the AAR file and added to app rules if consumed as a dependency.