Error inflating WebView XML

前端 未结 7 1523
佛祖请我去吃肉
佛祖请我去吃肉 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:42

    It seems that something strange occurred when the app was inflating the WebView, could be whatever. For the NameNotFoundException: com.google.android.webview problem with the Google packages

     if(getPackageManager().hasSystemFeature("android.software.webview") == true && isPackageExisted("com.google.android.webview")) {
                    if (Constant.isNetworkConnected(LoginActivity.this)) {
    
                         //Your Intent 
                    } else {
                        Toast.makeText(getApplicationContext(), resources.getString(R.string.internet_error), Toast.LENGTH_SHORT).show();
                    }
                }else
                    {
                        Constant.showDialog(LoginActivity.this,"Please install the webview");
                    }
            }
    

    //Make method for package check

    public boolean isPackageExisted(String targetPackage){
        List packages;
        PackageManager pm;
    
        pm = getPackageManager();
        packages = pm.getInstalledApplications(0);
        for (ApplicationInfo packageInfo : packages) {
            if(packageInfo.packageName.equals(targetPackage))
                return true;
        }
        return false;
    }
    

提交回复
热议问题