Ich erhalte Fehler von Crashlytics, die darauf hinweisen, dass auf einigen Geräten com.google.android.webview fehlt. Wie ist das überhaupt möglich?
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.app/com.myapp.ReaderActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class com.myapp.MyWebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class com.myapp.MyWebView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(SourceFile:206)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:297)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(SourceFile:228)
at android.support.v7.app.ActionBarActivity.setContentView(SourceFile:102)
at com.myapp.ReaderActivity.onCreate(SourceFile:120)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
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:607)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(SourceFile:206)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:297)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(SourceFile:228)
at android.support.v7.app.ActionBarActivity.setContentView(SourceFile:102)
at com.myapp.ReaderActivity.onCreate(SourceFile:120)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
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:2185)
at android.webkit.WebView.ensureProviderCreated(WebView.java:2180)
at android.webkit.WebView.setOverScrollMode(WebView.java:2239)
at android.view.View.(View.java:3581)
at android.view.View.(View.java:3675)
at android.view.ViewGroup.(ViewGroup.java:491)
at android.widget.AbsoluteLayout.(AbsoluteLayout.java:55)
at android.webkit.WebView.(WebView.java:538)
at android.webkit.WebView.(WebView.java:483)
at android.webkit.WebView.(WebView.java:466)
at android.webkit.WebView.(WebView.java:453)
at com.myapp.MyWebView.(SourceFile:31)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(SourceFile:206)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:297)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(SourceFile:228)
at android.support.v7.app.ActionBarActivity.setContentView(SourceFile:102)
at com.myapp.ReaderActivity.onCreate(SourceFile:120)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.content.pm.PackageManager$NameNotFoundException: com.google.android.webview
at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:114)
at android.webkit.WebViewFactory.getFactoryClass(WebViewFactory.java:133)
at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:101)
at android.webkit.WebView.getFactory(WebView.java:2185)
at android.webkit.WebView.ensureProviderCreated(WebView.java:2180)
at android.webkit.WebView.setOverScrollMode(WebView.java:2239)
at android.view.View.(View.java:3581)
at android.view.View.(View.java:3675)
at android.view.ViewGroup.(ViewGroup.java:491)
at android.widget.AbsoluteLayout.(AbsoluteLayout.java:55)
at android.webkit.WebView.(WebView.java:538)
at android.webkit.WebView.(WebView.java:483)
at android.webkit.WebView.(WebView.java:466)
at android.webkit.WebView.(WebView.java:453)
at com.myapp.MyWebView.(SourceFile:31)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(SourceFile:206)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(SourceFile:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(SourceFile:297)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:177)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:733)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(SourceFile:228)
at android.support.v7.app.ActionBarActivity.setContentView(SourceFile:102)
at com.myapp.ReaderActivity.onCreate(SourceFile:120)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Und es ist nur von Geräten, auf denen Lollipop ausgeführt wird. Ich habe es auf meinem Nexus 5 getestet, kann den Fehler jedoch nicht reproduzieren. Ich benutze Proguard
Mein MyWebView sieht folgendermaßen aus:
public class MyWebView extends WebView {
public static final String tag = MyWebView.class.getName();
private HtmlJSInterfaceNew js;
public MyWebView(Context context) {
super(context);
gd = new GestureDetector(context, sogl);
init();
}
public MyWebView(Context context, AttributeSet attrs) {
super(context, attrs);
gd = new GestureDetector(context, sogl);
init();
}
public MyWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
gd = new GestureDetector(context, sogl);
init();
}
@SuppressLint("NewApi")
private void init() {
setPadding(0, 0, 0, 0);
MyWebViewClient myWebViewClient = new MyWebViewClient();
this.setWebViewClient(myWebViewClient);
setWebChromeClient(new MyWebChromeClient());
if(!isInEditMode())
{
getSettings().setAllowFileAccess(true);
getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
getSettings().setJavaScriptEnabled(true);
WebSettings webSettings = getSettings();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
webSettings.setAllowContentAccess(false);
}
webSettings.setUseWideViewPort(true);
}
}
public void addMyJavascriptInterface(HtmlJSInterfaceNew htmlJSInterface, String string) {
js = htmlJSInterface;
addJavascriptInterface(htmlJSInterface, string);
}
public class MyWebChromeClient extends WebChromeClient
{
public void onProgressChanged(WebView view, int progress) {
}
}
}
Die Hauptursache ist:
android.util.AndroidRuntimeException: android.content.pm.PackageManager$NameNotFoundException: com.google.android.webview
at android.webkit.WebViewFactory.getFactoryClass(WebViewFactory.java:161)
Ich denke also, es könnte etwas mit Proguard und vielleicht dem JavascriptInterface zu tun haben. Irgendwelche Ideen?
EDIT: von grepcode habe ich die Methode getFactoryClass gefunden:
private static Class<WebViewFactoryProvider> getFactoryClass() throws ClassNotFoundException {
Application initialApplication = AppGlobals.getInitialApplication();
try {
// First fetch the package info so we can log the webview package version.
String packageName = getWebViewPackageName();
sPackageInfo = initialApplication.getPackageManager().getPackageInfo(packageName, 0);
Log.i(LOGTAG, "Loading " + packageName + " version " + sPackageInfo.versionName +
" (code " + sPackageInfo.versionCode + ")");
// Construct a package context to load the Java code into the current app.
Context webViewContext = initialApplication.createPackageContext(packageName,
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
initialApplication.getAssets().addAssetPath(
webViewContext.getApplicationInfo().sourceDir);
ClassLoader clazzLoader = webViewContext.getClassLoader();
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
try {
return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY, true,
clazzLoader);
} finally {
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
}
} catch (PackageManager.NameNotFoundException e) {
// If the package doesn't exist, then try loading the null WebView instead.
// If that succeeds, then this is a device without WebView support; if it fails then
// swallow the failure, complain that the real WebView is missing and rethrow the
// original exception.
try {
return (Class<WebViewFactoryProvider>) Class.forName(NULL_WEBVIEW_FACTORY);
} catch (ClassNotFoundException e2) {
// Ignore.
}
Log.e(LOGTAG, "Chromium WebView package does not exist", e);
throw new AndroidRuntimeException(e);
}
}
android
webview
proguard
android-5.0-lollipop
inflate-exception
Kasper Finne Nielsen
quelle
quelle
Antworten:
Es ist wahrscheinlich, dass dies in einem sehr kurzen Zeitraum unmittelbar nach dem Update der Android System WebView-Anwendung von Lollipop geschieht.
Ich hatte diesen Fehler in der Google Play Dev Console gesehen, konnte ihn aber auch nie auf meinem Nexus 5 reproduzieren, unabhängig davon, wie sehr ich wirklich versucht habe, meine App vom Zugriff auf die Android System WebView-App abzuhalten:
Dann erfuhren wir, dass unsere App auf einigen Geräten unmittelbar nach der Aktualisierung der System WebView-App ständig mit der obigen Meldung abstürzte, also habe ich das getestet. Immer noch keine Ergebnisse, das Vanille-Nexus 5 weigerte sich, unsere App zum Absturz zu bringen! Also habe ich andere Telefone anderer Hersteller ausprobiert (ungefähr 75% unserer Berichte stammen von Samsung Galaxy-Geräten) und plötzlich stürzten wir ständig ab. Meine Testmethode:
Ein paar kleine Vorbehalte zu dem, was ich bisher gesagt habe:
Kurz gesagt, ich glaube nicht sofort, dass Sie mit ProGuard oder Ihrem JavascriptInterface etwas falsch machen. Ich neige sehr stark dazu, die Firmware als Hauptursache für die meisten Berichte zu beschuldigen, was dazu führt, dass ein reibungsloser Aktualisierungsprozess zu einem Prozess wird, der stattdessen dazu führt, dass einige Apps sofort abstürzen.
Bearbeiten: Ich habe ein paar weitere Tests durchgeführt und es stellte sich heraus, dass alle Geräte, die nicht abgestürzt sind, 5.0 oder 5.0.1 sind, während alle Geräte, die abgestürzt sind, 5.0.2 waren, sodass ich nicht bequem mit dem Finger darauf zeigen kann OEMs nicht mehr.
quelle
Dies geschieht, wenn Chrome-Updates auf Android ausgeführt werden: Während des Updates zählt das Paket nicht als installiert, sodass der Versuch, es im Paketmanager nachzuschlagen, fehlschlägt.
In meinem Fall blieb es eine Weile länger bestehen (die App stürzte immer wieder ab), bis ich das Gerät tatsächlich neu startete / neu startete , dann ist alles in Ordnung.
Es ist nichts falsch an Ihrem Code, es ist nur, wie Updates behandelt werden.
Quelle: https://bugs.chromium.org/p/chromium/issues/detail?id=506369
quelle
Ich habe einen Weg gefunden, das Problem zu reproduzieren ( htc one (m8) android 6.0 ).
In meiner App verwende ich beim Start die Android System WebView- Komponente (in der Activity.onCreate () -Methode). Ich weiß, dass dies eine schlechte Praxis ist, aber dies ist nur zum Beispiel.
Schritte:
quelle