簡體   English   中英

我的 logcat 到底是什么意思,我該如何解決?

[英]What exactly does my logcat mean, and how can I fix it?

出於某種原因,我的應用程序喜歡在 API 23 (Marshmallow) 或更高版本上運行時運行良好。 但是當它試圖在 API 22 (Lollipop) 上運行時,它會立即崩潰,我只是不明白為什么。

我試過注釋掉除了最低限度之外的任何東西,但它仍然會這樣做。 我發現如果不注釋掉所有 webviews,應用程序甚至都不會啟動。

This is the logcat I got from trying to start the app in Android Studio emulating a Pixel 2 on API 22. And for further reference, yes, I tried it without my custom WebView class, and it still throws the same error.

09-22 15:07:55.644 3443-3443/? I/art: Not late-enabling -Xcheck:jni (already on)
09-22 15:07:55.727 3443-3443/test.webview W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter
 androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.
PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have
incorrectly overridden the package-private method in android.graphics.drawable.Drawable
09-22 15:07:55.749 3443-3443/test.webview I/art: Rejecting re-init on previously-failed class java.lang.Class<
androidx.core.view.ViewCompat$2>
09-22 15:07:55.750 3443-3443/test.webview I/art: Rejecting re-init on previously-failed class java.lang.Class<
androidx.core.view.ViewCompat$2>
09-22 15:07:55.808 3443-3443/test.webview I/WebViewFactory: Loading com.android.webview version 39 (5525941-x86_64
) (code 300008)
09-22 15:07:55.812 3443-3443/test.webview I/LibraryLoader: Time to load native libraries: 1 ms (timestamps 9226-
9227)
09-22 15:07:55.812 3443-3443/test.webview I/LibraryLoader: Expected native library version number "",actual native
 library version number ""
09-22 15:07:55.817 3443-3443/test.webview V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper
 (main, tid 1) {204b24c3}
09-22 15:07:55.817 3443-3443/test.webview I/LibraryLoader: Expected native library version number "",actual native
 library version number ""
09-22 15:07:55.817 3443-3443/test.webview I/chromium: [INFO:library_loader_hooks.cc(104)] Chromium logging enabled
: level = 0, default verbosity = 0
09-22 15:07:55.819 3443-3443/test.webview I/BrowserStartupController: Initializing chromium process, singleProcess
=true
09-22 15:07:55.820 3443-3443/test.webview W/art: Attempt to remove local handle scope entry from IRT, ignoring
09-22 15:07:55.827 3443-3443/test.webview W/chromium: [WARNING:resource_bundle.cc(304)] locale_file_path.empty()
09-22 15:07:55.828 3443-3443/test.webview I/chromium: [INFO:aw_browser_main_parts.cc(65)] Load from apk succesful
, fd=31 off=46184 len=3037
09-22 15:07:55.828 3443-3443/test.webview I/chromium: [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.
pak from, fd:32 off:229484 len:1089587
09-22 15:07:55.829 3443-3467/test.webview W/AudioManagerAndroid: Requires BLUETOOTH permission
09-22 15:07:55.854 3443-3443/test.webview D/EGL_emulation: eglCreateContext: 0x7fa99e8df2a0: maj 2 min 0 rcv 2
09-22 15:07:55.855 3443-3443/test.webview D/EGL_emulation: eglMakeCurrent: 0x7fa99e8df2a0: ver 2 0 (tinfo
0x7fa99e8d4a60)
09-22 15:07:55.877 3443-3443/test.webview W/chromium: [WARNING:data_reduction_proxy_settings.cc(331)] SPDY proxy
OFF at startup
09-22 15:07:55.882 3443-3443/test.webview W/ResourceType: No known package when getting value for resource number
0x02040003
09-22 15:07:55.882 3443-3443/test.webview D/AndroidRuntime: Shutting down VM
09-22 15:07:55.883 3443-3443/test.webview E/AndroidRuntime: FATAL EXCEPTION: main
 Process: test.webview, PID: 3443
 java.lang.RuntimeException: Unable to start activity ComponentInfo{test.webview/test.webview.MainActivity}:
android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
 at android.app.ActivityThread.access$800(ActivityThread.java:151)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5254)
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
 Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.
WebView
 at android.view.LayoutInflater.createView(LayoutInflater.java:633)
 at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
 at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
 at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
 at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
 at test.webview.MainActivity.onCreate(MainActivity.java:15)
 at android.app.Activity.performCreate(Activity.java:5990)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
 at android.app.ActivityThread.access$800(ActivityThread.java:151)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5254) 
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
 Caused by: java.lang.reflect.InvocationTargetException
 at java.lang.reflect.Constructor.newInstance(Native Method)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
 at android.view.LayoutInflater.createView(LayoutInflater.java:607)
 at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
 at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
 at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
 at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
 at test.webview.MainActivity.onCreate(MainActivity.java:15)
 at android.app.Activity.performCreate(Activity.java:5990)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
 at android.app.ActivityThread.access$800(ActivityThread.java:151)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5254)
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
 Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040003
 at android.content.res.Resources.getText(Resources.java:299)
 at android.content.res.Resources.getString(Resources.java:385)
 at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:684)
 at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:608)
 at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:
631)
 at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:780)
 at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:619)
 at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:556)
 at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:311)
 at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:96)
 at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:263)
 at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:
123)
 at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:110)
 at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
 at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:107)
 at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:260)
 at android.webkit.WebView.<init>(WebView.java:554)
 at android.webkit.WebView.<init>(WebView.java:489)
 at android.webkit.WebV

我期待它啟動(並且可能看起來不是最好的,因為 webview 支持在使用舊 API 時是不同的),但它似乎因為通貨膨脹異常而崩潰? (除非我讀錯了)

編輯:我剛剛嘗試使用 1 個 WebView 創建一個全新的應用程序,也很簡單,它也崩潰了。 這是activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

這是 MainActivity.java

package test.webview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webView);

        webView.loadUrl("https://google.com");
    }
}

如您所見,代碼沒有任何問題。 那么有什么問題呢? (你也可以在 Lollipop 上自己測試)

在您的MainActivity xml 中,您已聲明NoSuggestionsWebView class。

該錯誤說明在您的MainActivity xml 第 17 行NoSuggestionsWebView無法充氣。

您必須檢查NoSuggestionsWebView class 並檢查您是否正在做與操作系統相關的事情或類似的事情。

原來是舊版本的 Android 系統 Webview 包含在 AVD 中的一些錯誤,或者是因為 AppCompat 構建版本 (1.1.0) 中的錯誤。 做這個答案所說的,讓我的應用程序再次運行。 這對我有用,因為我在 1.1.0 中並沒有真正使用任何特殊的東西,所以使用 1.0.2 對androidx.appcompat:appcompat:1.0.2很好

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM