question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialAlertDialogBuilder] Creating MaterialAlertDialogBuilder crashes with ThemeEnforcement when using webview

See original GitHub issue

Description: Creating instance of MaterialAlertDialogBuilder causes the app crash with error message: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).

Weirdly enough, there are 2 conditions for it:

  1. Web view in Activity view or fragment.
  2. Using a wrapper for resources in Activity.getResources. Like:
override fun getResources(): Resources {
      return AppResources(super.getResources())
}
class AppResources(res: Resources) : Resources(res.assets, res.displayMetrics, res.configuration)

Android API version: 8.1 (it doesn’t crash in 10 or R)

Material Library version: 1.2.0-alpha05

Device: Android Emulator Android 8.1

ThemeEnforcementCrash.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hantrungkiencommented, Apr 29, 2020

@wcshi I have tested on android 7 and android 9. This PR also has merged.

This is not a bug in the Material library. This error occurs because when changing the configuration, some developers have created new Resource objects. This causes the application’s default theme to be changed and causes the Material library to throw an error.

0reactions
wcshicommented, Apr 29, 2020

Marking this as closed since it’s not a bug in the library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The specified child already has a parent, when using custom ...
MaterialAlertDialogBuilder crashes and shows error: The specified child already has a parent, when using custom view.
Read more >
How To Fix Android Apps Crashing Issue [2021 ... - YouTube
For those that are not able to uninstall Webview, long press on Google Chrome Browser. Go to App info and uninstall chrome updates....
Read more >
Untitled
am.java; by.java ... MaterialAlertDialogBuilder.java; MaterialDialogs.java ... TextWatcherAdapter.java; ViewOverlayApi14.java; ThemeEnforcement.java ...
Read more >
PSA: Random app crashes today? Uninstall Android Webview ...
I haven't done anything that would make me subseptible... So I figured it was correct & my phone was just corrupted by itself....
Read more >
MaterialAlertDialogBuilder crashes on custom vi...anycodings
Cast the DialogInterface to an anycodings_illegalstateexception AlertDialog and then use findViewById. Kotlin: val et = (dialog as?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found