我的应用程序在Google Play上,大部分设备上都可以正常运行(数千用户)。但在极少数情况下(每日活跃用户的一小部分),当我在onCreateView
方法中填充片段的布局时,会出现Error inflating class android.webkit.WebView
。
完整的堆栈跟踪如下:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tapmedia.tapito/com.tapmedia.tapito.LockscreenActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class android.webkit.WebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2694)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
at android.app.ActivityThread.access$900(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at com.tapmedia.tapito.WebViewFragment.onCreateView(SourceFile:84)
at android.support.v4.app.Fragment.performCreateView(SourceFile:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:924)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1116)
at android.support.v4.app.FragmentManagerImpl.onCreateView(SourceFile:2196)
at android.support.v4.app.FragmentActivity.onCreateView(SourceFile:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(SourceFile:838)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(SourceFile:34)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(SourceFile:826)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(SourceFile:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:249)
at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:106)
at com.tapmedia.tapito.LockscreenActivity.onCreate(SourceFile:103)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
at android.app.ActivityThread.access$900(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at com.tapmedia.tapito.WebViewFragment.onCreateView(SourceFile:84)
at android.support.v4.app.Fragment.performCreateView(SourceFile:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:924)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1116)
at android.support.v4.app.FragmentManagerImpl.onCreateView(SourceFile:2196)
at android.support.v4.app.FragmentActivity.onCreateView(SourceFile:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(SourceFile:838)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(SourceFile:34)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(SourceFile:826)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(SourceFile:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:249)
at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:106)
at com.tapmedia.tapito.LockscreenActivity.onCreate(SourceFile:103)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
at android.app.ActivityThread.access$900(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: android.util.AndroidRuntimeException: android.content.pm.PackageManager$NameNotFoundException: com.google.android.webview
at android.webkit.WebViewFactory.getFactoryClass(WebViewFactory.java:161)
at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:101)
at android.webkit.WebView.getFactory(WebView.java:2193)
at android.webkit.WebView.ensureProviderCreated(WebView.java:2188)
at android.webkit.WebView.setOverScrollMode(WebView.java:2247)
at android.view.View.(View.java:3795)
at android.view.View.(View.java:3909)
at android.view.ViewGroup.(ViewGroup.java:507)
at android.widget.AbsoluteLayout.(AbsoluteLayout.java:55)
at android.webkit.WebView.(WebView.java:547)
at android.webkit.WebView.(WebView.java:492)
at android.webkit.WebView.(WebView.java:475)
at android.webkit.WebView.(WebView.java:462)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at com.tapmedia.tapito.WebViewFragment.onCreateView(SourceFile:84)
at android.support.v4.app.Fragment.performCreateView(SourceFile:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:924)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1116)
at android.support.v4.app.FragmentManagerImpl.onCreateView(SourceFile:2196)
at android.support.v4.app.FragmentActivity.onCreateView(SourceFile:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(SourceFile:838)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(SourceFile:34)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(SourceFile:826)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(SourceFile:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:249)
at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:106)
at com.tapmedia.tapito.LockscreenActivity.onCreate(SourceFile:103)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
at android.app.ActivityThread.access$900(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: android.content.pm.PackageManager$NameNotFoundException: com.google.android.webview
at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:137)
at android.webkit.WebViewFactory.getFactoryClass(WebViewFactory.java:133)
at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:101)
at android.webkit.WebView.getFactory(WebView.java:2193)
at android.webkit.WebView.ensureProviderCreated(WebView.java:2188)
at android.webkit.WebView.setOverScrollMode(WebView.java:2247)
at android.view.View.(View.java:3795)
at android.view.View.(View.java:3909)
at android.view.ViewGroup.(ViewGroup.java:507)
at android.widget.AbsoluteLayout.(AbsoluteLayout.java:55)
at android.webkit.WebView.(WebView.java:547)
at android.webkit.WebView.(WebView.java:492)
at android.webkit.WebView.(WebView.java:475)
at android.webkit.WebView.(WebView.java:462)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at com.tapmedia.tapito.WebViewFragment.onCreateView(SourceFile:84)
at android.support.v4.app.Fragment.performCreateView(SourceFile:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:924)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1116)
at android.support.v4.app.FragmentManagerImpl.onCreateView(SourceFile:2196)
at android.support.v4.app.FragmentActivity.onCreateView(SourceFile:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(SourceFile:838)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(SourceFile:34)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(SourceFile:826)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(SourceFile:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:732)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:249)
at android.support.v7.app.AppCompatActivity.setContentView(SourceFile:106)
at com.tapmedia.tapito.LockscreenActivity.onCreate(SourceFile:103)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2759)
at android.app.ActivityThread.access$900(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5944)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
我不明白出了什么问题。因为这个错误来自在线报告工具(Crashlytics/Fabric),我无法确定,特定用户每次尝试使用片段时是否会发生,或者用户通常是否可以展开片段并且错误只是偶尔发生。 WebView小部件是系统的一部分,对吧?我的意思是说-我不可能在我的生产APK中缺少任何东西-像支持库之类的。还是可以呢?
com.google.android.webview
),但出于某种原因找不到它。 - CommonsWareTextView
或ImageView
小部件。 - Shayan Pourvatan