gbwisx / msal_mobile

Flutter plugin for single client authentication using the Microsoft Authentication Library (MSAL)
MIT License
10 stars 26 forks source link

Initialization error on release mode #19

Open Zazo032 opened 3 years ago

Zazo032 commented 3 years ago

I've set up the plugin and it works correctly on debug/profile modes, but when I run it on release mode, I always get this error when the plugin is initialized:

E/flutter (31094): [ERROR:flutter/lib/ui/ui_dart_state.cc(213)] Unhandled Exception: type 'Null' is not a subtype of type 'bool'
E/flutter (31094): #0      new MsalMobileResult.fromJson (package:msal_mobile/result.dart:13)
E/flutter (31094): #1      MsalMobile.create (package:msal_mobile/msal_mobile.dart:45)

However, if I set minifyEnabled false in android/app/build.gradle, it works as intended, but the app size goes a lot bigger. I've tried adding many Proguard rules, but that doesn't seem to work.

I'm using https://github.com/gbwisx/msal_mobile/pull/15

Zazo032 commented 3 years ago

When minified, the result being passed to Flutter looks like this:

{"a":true,"d":true,"e":false}

But without minify enabled, it looks like this:

{"isSuccess":true,"isUiRequired":false,"payload":true}

Therefore, when the plugin tries to read the following code on Flutter side, it fails, because the keys got minified and changed to other values:

isSuccess: json['isSuccess'],

For some reason, the json keys are getting minified.