microsoft-authentication-library-for-android icon indicating copy to clipboard operation
microsoft-authentication-library-for-android copied to clipboard

MSAL version 4.6.3 cannot be authenticated on Android 5.0 & 4.4.4

Open weedcry opened this issue 2 years ago • 10 comments

Describe the bug I have implemented MSAL version 4.6.3 in my project and when I try to authenticate (MultipleAccount) on Android 5.0.2, an error occurs that causes the app to crash. Previously, I had implemented the same on Android 7.0 and it works fine.

I also tried to download the source sample at (https://github.com/Azure-Samples/ms-identity-android-java) Implemented MSAL version 4.6.3 and tried to authenticate (MultipleAccount) on Android 5.0.2 and android 4.4.4, and the same error occurs as mentioned above. The source sample at Android 7.0 still works fine.

I see that the MSAL library requires Android API Level 16+, so I think it should still work fine on Android 5.0.2 & 4.4.4.

Smartphone

  • Android Version: 5.0.2 & 4.4.4
  • MSAL Version 4.6.3

Additional context The error I received at source sample log.txt

weedcry avatar Aug 02 '23 06:08 weedcry

@weedcry The issue is shared with engineering team we will get back to you soon once we have prioritized. Thanks.

negoe avatar Aug 21 '23 04:08 negoe

@weedcry The issue is shared with engineering team we will get back to you soon once we have prioritized. Thanks.

Thanks

weedcry avatar Aug 21 '23 09:08 weedcry

Hi @weedcry, Thanks for your patience. The team has been occupied with some high priority work items. Can you please try and upgrading to latest version that is 4.9.0 and let me know if the problem persists?

negoe avatar Oct 19 '23 18:10 negoe

Hi @negoe We are also experiencing this issue. We're on the latest version: 4.9.0.

Aaron-Constance avatar Oct 31 '23 13:10 Aaron-Constance

Hi @negoe I have checked on MSAL version 4.9.0 and 4.10.0 (latest version), the same error still continues on Android 4.4.4.

weedcry avatar Nov 28 '23 10:11 weedcry

This was fixed in : https://github.com/AzureAD/microsoft-authentication-library-for-android/pull/2003

Correction 2/5/24: The fix shared above is not for this issue but is for a different open telemetry related issue.

negoe avatar Jan 29 '24 02:01 negoe

Hi @weedcry and @Aaron-Constance, can you please upgrade to the latest version and let me know if you are still experiencing the issue?

negoe avatar Mar 26 '24 14:03 negoe

Hi @negoe I have tried using MSAL for Android at version 5.2.0 (latest) on an Android 4.4.4 device and the same error still appears. The app crashes with the following log exception_MSAL.txt However, the app works normally on an Android 7.0 device. I think that the current latest version still hasn’t resolved this issue.

weedcry avatar Mar 27 '24 09:03 weedcry

Unfortunately, we do not see any other customers sharing the same issue so it really difficult for us to prioritize it. We are keeping an eye and will keep checking if more customers get impacted, we will definitely prioritize this work.

negoe avatar Mar 28 '24 18:03 negoe

Any solution we have the same problem in the version 5.3.1, the minimum Android version compatible is 7

Javs-21 avatar Jun 14 '24 15:06 Javs-21

Hi! I recently had a similar but different issue with MSAL 6.+, up to the current 6.2.0 version and would like to share a workaround I found. Similar, because MSAL works fine on Android 7+, and crashes on older OS versions. Different, because I used recent library version and my crash report looks like this: I experienced crashes only on Android 6 (it's my minSdkVersion, but I'm pretty sure older OS versions are also affected, more on that later). Crashes occurred immediately after invoking MSAL with NoClassDefFoundError. The core of the problem lies in common library at line:

org.apache.hc.core5.net.URIBuilder.setParameter (URIBuilder.java:805)
com.microsoft.identity.common.java.util.CommonURIBuilder.setParameter (CommonURIBuilder.java:82)

The problem is, as per documentation, setParameter function of URIBuilder class uses Java 8 APIs (specifically at URIBuilder.java:805 it calls Collection.removeIf(Predicate filter)). In short - this means that it will work natively starting from Android 7, as this version introduced the first subset of Java 8 API support (including Collection.removeIf mentioned above).

In order to fix it, at the cost of slightly increased apk size, you need to enable core library desugaring in your project, and missing functions will be backported and integrated into the code of your app. I tested it on Android Emulator, and I can confirm, it fixes my issue with crashing on pre Android 7 devices. Without core library desugaring the app always crashes, but after enabling it, I could log in with MSAL on Android 6 without any problems.

If anyone is currently having trouble with MSAL support on Android 6 or earlier, this workaround might help.

Marcin-Kuczala avatar Jul 24 '25 19:07 Marcin-Kuczala