Error inflating WebView XML

前端 未结 7 1571
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 00:10

I found a crash report on Crashlytics in a Samsung SM G920F (Galaxy S6), version 5.1.1 (on all other devices I didn\'t retrieve same error).

java.lang.Runtim         


        
7条回答
  •  自闭症患者
    2021-01-04 00:46

    This crash problem happens on Android 5.0 and 5.1 Lollipop (API 21/22), when using version 1.1.0 of some AndroidX Jetpack libraries:

    implementation "androidx.appcompat:appcompat:1.1.0"
    

    or

    implementation "androidx.preference:preference:1.1.0"
    

    It happens when your device does not have Google Chrome browser or "Android System WebView" installed from the Google Play Store. Some stock emulators that don't have Google Play Services installed will therefore experience this problem.

    How to Solve

    Updating to a higher AndroidX version, like 1.2.0-alpha03 will fix it, as mentioned here:

    Error inflating class android.webkit.WebView Crash on Lollipop when opening PDF

    implementation "androidx.appcompat:appcompat:1.2.0-alpha03"
    

    Or use a custom fix in AppCompatActivity.applyOverrideConfiguration(). See: android.view.InflateException Error inflating class android.webkit.WebView

    See also:

    • WebView Crash on Android 5-5.1 (API 21-22) Resources$NotFoundException: String resource ID #0x2040002
    • https://issuetracker.google.com/issues/141132133 -- "webview crashes with appcompat1.1.0"

提交回复
热议问题