[MaterialAlertDialogBuilder] Creating MaterialAlertDialogBuilder crashes with ThemeEnforcement when using webview
See original GitHub issueDescription: 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:
- Web view in Activity view or fragment.
- 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
Marking this as closed since it’s not a bug in the library.