Closed asad-baidar closed 3 days ago
I found a few problems with this issue:
Here is a sample repository to test. https://github.com/asadbaidar/flutter_intune_project
Hi @asad-baidar, thank you for reaching out. I tried reproducing the issue, however, I'm encountering a different issue.
I ran the following commands:
// To configure the apps
$ flutterfire configure
// and
$ flutter pub get
$ dart run build_runner build --delete-conflicting-outputs
$ cd app/kanban
$ flutter run --flavor dev --target lib/main_dev.dart
Then, below is the error I'm getting
I'm not familiar with the Inture MAM. However, The ClassCastException
suggests that the app is trying to cast an object of type com.microsoft.intune.mam.client.content.MAMContext
to android.app.Application
. This likely happens because of a conflict between Firebase and Microsoft Intune MAM integration.
Have you tried running your app with Firebase integration only? This will help us eliminate a possible issue that Firebase is not being initialized properly
Hi @lehcar09 Thank you for looking into it. I just pushed a fix. please take the pull again and run clean. And no need to run flutterfire configure. as the project already has firebase configured.
And yes when I build without Firebase but keep Intune, it works fine. no crash then. same with removing Intune but keeping Firebase also works.
about cast issue it is within the Firebase SDK which should not occur as Context is not an instance of Application maybe something is wrong with the Firebase?
Hey @asad-baidar, I tried running your MCVE again and the app launched without any issue.
The only difference in the setup you share is that I ran the flutterfire configure
that generates the firebase_options file that contains the Firebase configuration as mentioned in our documentation.
Can you share how you initialize Firebase?
Hi @lehcar09 I added the google-services.json for configuration. firebase app automatically pick those if not provided in flutter init.
Secondly you need to install Intune company portal first in the phone. Intune SDK gets activated when that is configured. its then the app starts crashing. as I mentioned in the initial description. without intune setup, app works fine.
Hey @asad-baidar, thank you for your clarification. Per checking with our engineers, based on your logs, the cause of the exception is Caused by: java.lang.ClassCastException: com.microsoft.intune.mam.client.content.MAMContext cannot be cast to android.app.Application
that seems to be related this MS Intune Android SDK issue (#172).
Could you check if the solution shared in this comment will resolve your issue?
Hey @asad-baidar, thank you for your clarification. Per checking with our engineers, based on your logs, the cause of the exception is
Caused by: java.lang.ClassCastException: com.microsoft.intune.mam.client.content.MAMContext cannot be cast to android.app.Application
that seems to be related this MS Intune Android SDK issue (#172).Could you check if the solution shared in this comment will resolve your issue?
Hi @lehcar09 Yes I previously checked that comment and manifest in flutter already uses FlutterApplication and there seems to be nothing wrong there. As that comment says he missed the application tag but I didn't.
@asad-baidar This may have something to do with android level API changes. What phone are you using, and what API level is it?
@asad-baidar
This may have something to do with android level API changes. What phone are you using, and what API level is it?
@daymxn min API is 28 and building with 34. Used pixel and xiaomi phones and emulators. All behave same.
Hi @lehcar09 , is there any update?
@lehcar09 you were right. I thought Flutter always uses FlutterApplication
instead of android.app.Application
, but it turns out it doesn’t so I can safely replace name
tag with com.microsoft.intune.mam.client.app.MAMApplication
. This fixed the crash and it is working well now. Closing the issue. Thank you.
<manifest
...
<application
...
android:name="com.microsoft.intune.mam.client.app.MAMApplication"
...>
>
Environment
Problem
In Flutter Android app, when MAM is enabled it compiles and runs fine but when the inTune company portal app is installed and configured on the device, the App crashes on launch. When we remove Firebase dependencies then App works fine and does not crash.
Steps to reproduce:
In the Flutter application, add inTune SDK dependencies in Android Gradle files. Install InTune company portal app and configure the MAM. Now launching the Flutter MAM app will crash.
Relevant Code:
No code required, just add the SDK dependencies in gradle and enable InTune gradle plugin.
build.gradle
and SDK AAR Intune Android App SDK Version: 10.3.1
Crash Logs: