2012-11-15 373 views
1

我得到這個奇怪的錯誤嘗試在我的佈局NullPointerException異常Android中

11-15 10:49:30.790: E/AndroidRuntime(18749): FATAL EXCEPTION: main 
11-15 10:49:30.790: E/AndroidRuntime(18749): android.view.InflateException: Binary XML file line #9: Error inflating class android.webkit.WebView 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.createView(LayoutInflater.java:613) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at com.philly.prosportsframework.fragments.HomeLauncherFragment.buildView(HomeLauncherFragment.java:317) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at com.philly.prosportsframework.fragments.HomeLauncherFragment$LauncherListAdapter.getView(HomeLauncherFragment.java:299) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.AbsListView.obtainView(AbsListView.java:2267) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.ListView.measureHeightOfChildren(ListView.java:1244) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.ListView.onMeasure(ListView.java:1156) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.View.measure(View.java:15172) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.Choreographer.doCallbacks(Choreographer.java:555) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.Choreographer.doFrame(Choreographer.java:525) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.os.Handler.handleCallback(Handler.java:615) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.os.Handler.dispatchMessage(Handler.java:92) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.os.Looper.loop(Looper.java:137) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at android.app.ActivityThread.main(ActivityThread.java:4745) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at java.lang.reflect.Method.invokeNative(Native Method) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at java.lang.reflect.Method.invoke(Method.java:511) 
11-15 10:49:30.790: E/AndroidRuntime(18749): at c 
11-15 10:49:30.850: D/dalvikvm(18749): GC_CONCURRENT freed 314K, 6% free 7612K/8071K, paused 13ms+4ms, total 51ms 
11-15 10:49:30.850: E/System(18749): Uncaught exception thrown by finalizer 
11-15 10:49:30.850: E/System(18749): java.lang.NullPointerException 
11-15 10:49:30.850: E/System(18749): at android.webkit.WebViewClassic.destroyJava(WebViewClassic.java:2087) 
11-15 10:49:30.850: E/System(18749): at android.webkit.WebViewClassic.destroy(WebViewClassic.java:2072) 
11-15 10:49:30.850: E/System(18749): at android.webkit.WebViewClassic.finalize(WebViewClassic.java:4126) 
11-15 10:49:30.850: E/System(18749): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:186) 
11-15 10:49:30.850: E/System(18749): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169) 
11-15 10:49:30.850: E/System(18749): at java.lang.Thread.run(Thread.java:856) 

是在跟蹤中引用的代碼行的一個充氣網頁視圖充氣網頁視圖時是:

v = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_launcher_item, null); 

和佈局文件看起來像這樣:

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


      <WebView 
     android:id="@+id/photo" 
     android:layout_width="330dip" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true"   
     android:background="@drawable/thumb"/> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"     
     android:layout_above="@+id/byline" 
     android:layout_alignRight="@+id/photo" 
     android:layout_marginTop="20px" 
     android:textColor="#ffffffff" 
     android:textSize="25px" 
     android:lines="2" 
     android:background="#dd000000"/>     

    <TextView 
     android:id="@+id/byline"  
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/photo" 
     android:layout_alignRight="@+id/photo" 
     android:textColor="#ff565656" 
     android:textStyle="italic" 
     android:background="#dd000000"/> 
</RelativeLayout> 

任何想法將是有益的。我正在使用運行Android 4.1.1的Xoom進行測試。

+1

很難看 - 什麼是父母? –

+4

你確實擁有'res/drawable/thumb.png'資源嗎? – fiddler

+1

您的Manifest中是否有互聯網許可? <使用權限android:name =「android.permission.INTERNET」/> – JeffG

回答

0

res/drawable/thumb.png可能丟失。您需要添加它或將引用更改爲現有的可繪製資源。

XML佈局驗證程序有時會出錯。不要相信他;)

相關問題