gpt4 book ai didi

java - 加载 webview 时错误膨胀类 android.webkit.WebView

转载 作者:数据小太阳 更新时间:2023-10-29 02:35:08 26 4
gpt4 key购买 nike

我以前从未遇到过这个问题,我的设置与以前的情况几乎相同。

错误本身是:

android.view.InflateException: Binary XML file line #7: 
Error inflating class android.webkit.WebView

我正在像这样在 XML 文件中启动一个 WebView:

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

<WebView
android:id="@+id/facebookWebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp" />

</RelativeLayout>

我正在使用选项卡 fragment ,启动 xml 文件的 fragment 是这样的:

public class FragmentTab1 extends Fragment{

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.tabfacebook, container, false);

// allocate and instanciate webview
WebView webView = (WebView) view.findViewById(R.id.facebookWebview);
webView.getSettings().setJavaScriptEnabled(true);

// load fb url into it
webView.loadUrl("https://www.facebook.com/urlinhere");

webView.setWebViewClient(new WebViewClient(){

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {

Log.d("TAG", " ==> " + url);
view.loadUrl(url);
return true;
}

});

return view;
}
}

再一次,这是我一直以来所做的。我已经注释掉了这段代码的大部分,以查看问题是否出在此处,但问题出在 XML 文件中而不是 .java 文件中。

有什么建议吗?

编辑:整个堆栈跟踪

09-07 09:19:06.870    1150-1150/ourpackage.com.ourpackage E/WebViewFactory﹕ Chromium WebView does not exist
09-07 09:19:06.910 1150-1150/ourpackage.com.ourpackage E/WebViewFactory﹕ Chromium WebView does not exist
09-07 09:19:06.910 1150-1150/ourpackage.com.ourpackage D/AndroidRuntime﹕ Shutting down VM
09-07 09:19:06.910 1150-1150/ourpackage.com.ourpackage W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb1a46d70)


android.view.InflateException: Binary XML file line #7: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:57)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at ourpackage.com.ourpackage.FragmentTab1.onCreateView(FragmentTab1.java:22)
at android.app.Fragment.performCreateView(Fragment.java:1701)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1063)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1448)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:57)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at ourpackage.com.ourpackage.FragmentTab1.onCreateView(FragmentTab1.java:22)
            at android.app.Fragment.performCreateView(Fragment.java:1701)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1063)
            at android.app.BackStackRecord.run(BackStackRecord.java:684)
            at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1448)
            at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5026)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsupportedOperationException
at com.android.webview.nullwebview.NullWebViewFactoryProvider.createWebView(NullWebViewFactoryProvider.java:41)
at android.webkit.WebView.ensureProviderCreated(WebView.java:2058)
at android.webkit.WebView.setOverScrollMode(WebView.java:2116)
at android.view.View.<init>(View.java:3461)
at android.view.View.<init>(View.java:3517)
at android.view.ViewGroup.<init>(ViewGroup.java:470)
at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:52)
at android.webkit.WebView.<init>(WebView.java:498)
at android.webkit.WebView.<init>(WebView.java:475)
at android.webkit.WebView.<init>(WebView.java:455)
at android.webkit.WebView.<init>(WebView.java:444)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:594)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:57)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at ourpackage.com.ourpackage.FragmentTab1.onCreateView(FragmentTab1.java:22)
            at android.app.Fragment.performCreateView(Fragment.java:1701)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1063)
            at android.app.BackStackRecord.run(BackStackRecord.java:684)
            at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1448)
            at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5026)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
            at dalvik.system.NativeStart.main(Native Method)

我检查了我的 SDK 管理器,里面的一切都是最新的

最佳答案

感谢 Tom R 的回答。

如果其他人遇到类似问题,请检查您运行的是什么模拟器。

看来我正在为 Android Wear, more info can be found here on this if you are unaware 运行模拟器.

通过将其更改为 Wear ARM 中的标准 ARM CPU 修复了此问题

关于java - 加载 webview 时错误膨胀类 android.webkit.WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25708825/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com