heap / react-native-heap

A React Native integration for Heap
MIT License
82 stars 36 forks source link

[Android] Crash on app launch when also integrating Intune #302

Closed gtfunes closed 2 years ago

gtfunes commented 2 years ago

Hey! So the app I'm developing integrates Heap and also Microsoft Intune. Intune is a MAM service to add extra security to corporate devices. It replaces some classes and methods to enable the enforcement of some security policies.

My issue is that when running this app, seems like both libraries collide with the following error:

E/ncaughtExceptionHandler: Uncaught exception in app
    java.lang.AssertionError: HeapAssert.fail() with throwable: java.lang.ClassCastException: com.microsoft.intune.mam.client.content.MAMContext cannot be cast to android.app.Application
        at com.heapanalytics.android.internal.HeapContentProvider.unsafeOnCreate(HeapContentProvider.java:41)
        at com.heapanalytics.android.internal.HeapContentProvider.onCreate(HeapContentProvider.java:26)

From what I could see on the decompiled class file on Android Studio, seems like this is the issue on the Heap Android SDK's HeapContentProvider:

    private boolean unsafeOnCreate() {
        Context c = this.getContext();
        HeapActivityLifecycleCallbacks callbacks = new HeapActivityLifecycleCallbacks(EventSuppressor.INSTANCE);
        ((Application)c).registerActivityLifecycleCallbacks(callbacks);
        [...]

I know this is probably beyond the scope of support from Heap, but if anyone has any ideas on how to get around this issue or any fixes that could be done on the library's side, I would greatly appreciate it!

MCeley commented 2 years ago

@gtfunes This issue has been addressed in Heap Android SDK version 1.10.3. Please update to Heap React Native SDK 0.20.0 to use the latest Heap native versions.

gtfunes commented 2 years ago

@gtfunes This issue has been addressed in Heap Android SDK version 1.10.3. Please update to Heap React Native SDK 0.20.0 to use the latest Heap native versions.

Perfect, thanks!