microsoftconnect / ms-intune-app-sdk-android

Intune App SDK for Android enables data protection features and mobile app management via Microsoft Intune
43 stars 17 forks source link

App crashing due to theming issue when trying to calling `ApprovedKeyboardsDialogHelper.showKeyboardInstallDialog` #142

Open daniel-m-dd opened 1 year ago

daniel-m-dd commented 1 year ago

Hello I am encountering this crash when integrating and testing the MS intune SDK. Thanks!

Describe the bug:

App with the Intune SDK included is crashing when trying to show the Intune keyboard dialog.

android.view.InflateException: Binary XML file line #80 in android:layout/alert_dialog_material: Binary XML file line #37 in android:layout/alert_dialog_button_bar_material: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #37 in android:layout/alert_dialog_button_bar_material: Error inflating class Button
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).

I did check that my app is correctly using a Theme.AppCompat (more precisely we are using MaterialTheme) and could also a dialog when calling/building the dialog manually. Besides I do get other dialogs working correctly. Example: when restricting the allowed browser to Edge; the dialog asking to download Edge is correctly shown.

My guess is the Intune wrapper is somewhere using the application context instead of the activity context when building the dialog.

To Reproduce Steps to reproduce the behavior:

  1. Create a policy not allowing any keyboard installed on your device
  2. Open your app with the ms-intne sdk integrated and try to search/type something in a androidx.appcompat.widget.SearchView view
  3. See crash

Expected behavior: Should not crash and show the appropriate ms intune helper dialog

Screenshots and logs:

Stacktrace:


Process: myapp.package.name, PID: 27544
android.view.InflateException: Binary XML file line #80 in android:layout/alert_dialog_material: Binary XML file line #37 in android:layout/alert_dialog_button_bar_material: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #37 in android:layout/alert_dialog_button_bar_material: Error inflating class Button
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
    at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:241)
    at com.google.android.material.internal.ThemeEnforcement.checkAppCompatTheme(ThemeEnforcement.java:211)
    at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:146)
    at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:75)
    at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:228)
    at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:219)
    at com.google.android.material.theme.MaterialComponentsViewInflater.createButton(MaterialComponentsViewInflater.java:43)
    at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:129)
    at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1569)
    at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1620)
    at com.microsoft.intune.mam.client.view.LayoutInflaterManagementBehaviorImpl$FactoryWrapper.onCreateView(:78)
    at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1061)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1263)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:1119)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:541)
    at com.android.internal.app.AlertController.installContent(AlertController.java:291)
    at android.app.AlertDialog.onCreate(AlertDialog.java:443)
    at android.app.Dialog.dispatchOnCreate(Dialog.java:702)
    at android.app.Dialog.show(Dialog.java:424)
    at com.microsoft.intune.mam.client.view.ApprovedKeyboardsDialogHelper.showKeyboardInstallDialog(:253)
    at com.microsoft.intune.mam.client.view.ApprovedKeyboardsDialogHelper.restrictKeyboards(:164)
    at com.microsoft.intune.mam.client.view.ApprovedKeyboardsDialogHelper.showKeyboardRestrictedDialogIfNecessary(:143)
    at com.microsoft.intune.mam.client.view.EditorViewBehaviorImpl.onCreateInputConnection(:96)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.microsoft.intune.mam.InterProxy$InterInvocationHandler.invoke(:88)
    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    at $Proxy37.onCreateInputConnection(Unknown Source)
    at com.microsoft.intune.mam.client.widget.MAMAutoCompleteTextView.onCreateInputConnection(MAMAutoCompleteTextView.java:90)
    at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:2118)
    at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:2452)
    at android.view.inputmethod.InputMethodManager.displayCompletions(InputMethodManager.java:1430)
    at android.widget.AutoCompleteTextView.dismissDropDown(AutoCompleteTextView.java:1206)

Smartphone (please complete the following information):

Intune App SDK for Android (please complete the following information):

Additional context: Add any other context about the problem here.

meghandaly commented 1 year ago

@daniel-m-dd Thank you for reporting this issue. We are looking into reproducing this internally. In the meantime, can you reproduce the scenario and share the Incident ID from the Company Portal logs?

meghandaly commented 1 year ago

MAM Note: Tracking internally with #17015578

daniel-m-dd commented 1 year ago

@meghandaly Here is the incident id: DYYQPBG3. Thanks!

codylund commented 1 year ago

@daniel-m-dd are you still having this issue? Do you mind sharing any custom theme settings for your app, or a minimal sample application that reproduces the issue?

When attempting to reproduce this issue with SearchView in androidx.appcompat:appcompat:1.6.1, I could not use SearchView without switching the app's theme to Theme.AppCompat (or a descendant). Did you make a similar change in your app? If you are able to successfully use SearchView, it is surprising that the MAM SDK's keyboard install dialog would throw an error because it "requires your app theme to be Theme.AppCompat (or a descendant)."

daniel-m-dd commented 1 year ago

@codylund Yes, I am still having the issue. Our app is using the Theme.MaterialComponents.DayNight.NoActionBar but overriding the attribute with Widget.AppCompat.SearchView.ActionBar. However not overriding searchViewStyle does not fix it either and seem unrelated...

Side note 1: we are using androidx.appcompat:appcompat:1.5.1 but upgrading to 1.6.1 had no impact. Side note 2: we also ruled out this issue