我知道在stackoverflow上有一堆類似的問題。 但這些都不能解決我的問題。Android - 擴充文本視圖的錯誤
這不是關於主題設置或資源未找到。 而我沒有在這個佈局中加載大圖片(所有的背景都來自drawable xml)。 所有屬性都有準確的值,包括名稱空間聲明。 它只是隨機拋出這個異常。 看起來像一個android bug。
它發生在Nexus 5X,Nexus 6P,HTC_A9u,ASUS_Z012等。 我使用API 25,支持庫25.0.1,構建工具25.0.2。
它開始後,我改變使用API報告這一異常25
有與ScrollView
佈局20個類似的節點。 和Fragment
擁有此佈局。 我用片段事務初始化它,然後把它放在DrawerLayout
。
佈局節點:
<ScrollView
android:id="@+id/mainMenuScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
<RelativeLayout
android:id="@+id/aboutHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingTop="7dp"
android:paddingBottom="7dp"
android:paddingStart="10dp"
android:paddingEnd="5dp"
android:clickable="true"
android:background="?theme.mainMenuItemBackground"
android:layout_below="@+id/otherHolder">
<TextView
android:id="@+id/aboutCapital"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:background="@drawable/my_background"
android:gravity="center"
android:textSize="14sp"
android:textColor="?theme.titleColor"
android:text="A"/>
<TextView
android:id="@+id/aboutName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/aboutCapital"
android:textStyle="bold"
android:textSize="@dimen/menu_item_title"
android:textColor="?theme.titleColor"
android:text="About"/>
</RelativeLayout>
...
</RelativeLayout>
</ScrollView>
它也發生在ScrollView
或類似<unknown>
。
錯誤日誌(TextView
):
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.LauncherActivity}: android.view.InflateException: Binary XML file line #813: Binary XML file line #813: Error inflating class TextView
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2665)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)
Caused by android.view.InflateException: Binary XML file line #813: Binary XML file line #813: Error inflating class TextView
Caused by android.view.InflateException: Binary XML file line #813: Error inflating class TextView
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
android.content.res.AssetManager.getPooledStringForCookie (AssetManager.java:306)
android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1217)
android.content.res.TypedArray.getValueAt (TypedArray.java:1203)
android.content.res.TypedArray.getColorStateList (TypedArray.java:526)
android.widget.TextView.<init> (TextView.java:1080)
android.widget.TextView.<init> (TextView.java:704)
android.support.v7.widget.AppCompatTextView.<init> (AppCompatTextView.java:62)
android.support.v7.widget.AppCompatTextView.<init> (AppCompatTextView.java:58)
android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:103)
android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1017)
android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1076)
android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView (LayoutInflaterCompatHC.java:44)
android.view.LayoutInflater$FactoryMerger.onCreateView (LayoutInflater.java:192)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:769)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:306)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2193)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6696)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2628)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)
錯誤日誌(<unknown>
)
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.LauncherActivity}: android.view.InflateException: Binary XML file line #1051: Binary XML file line #1051: Error inflating class <unknown>
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2666)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2727)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1478)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6121)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:876)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:766)
Caused by android.view.InflateException: Binary XML file line #1051: Binary XML file line #1051: Error inflating class <unknown>
Caused by android.view.InflateException: Binary XML file line #1051: Error inflating class <unknown>
Caused by java.lang.reflect.InvocationTargetException:
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:306)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2193)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6699)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2629)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2727)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1478)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6121)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:876)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:766)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
android.content.res.AssetManager.getPooledStringForCookie (AssetManager.java:306)
android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1217)
android.content.res.TypedArray.getValueAt (TypedArray.java:1203)
android.content.res.TypedArray.getDrawable (TypedArray.java:923)
android.view.View.<init> (View.java:4202)
android.view.ViewGroup.<init> (ViewGroup.java:579)
android.widget.RelativeLayout.<init> (RelativeLayout.java:248)
android.widget.RelativeLayout.<init> (RelativeLayout.java:244)
android.widget.RelativeLayout.<init> (RelativeLayout.java:240)
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:306)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2193)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6699)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2629)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2727)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1478)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6121)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:876)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:766)
錯誤日誌(ScrollView
):
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.LauncherActivity}: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class android.widget.ScrollView
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2665)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)
Caused by android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class android.widget.ScrollView
Caused by android.view.InflateException: Binary XML file line #13: Error inflating class android.widget.ScrollView
Caused by java.lang.reflect.InvocationTargetException:
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:288)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2196)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6696)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2628)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
android.content.res.AssetManager.getPooledStringForCookie (AssetManager.java:306)
android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1217)
android.content.res.TypedArray.getValueAt (TypedArray.java:1203)
android.content.res.TypedArray.getDrawable (TypedArray.java:923)
android.view.View.initializeScrollbarsInternal (View.java:5133)
android.view.View.<init> (View.java:4660)
android.view.ViewGroup.<init> (ViewGroup.java:579)
android.widget.FrameLayout.<init> (FrameLayout.java:92)
android.widget.ScrollView.<init> (ScrollView.java:180)
android.widget.ScrollView.<init> (ScrollView.java:176)
android.widget.ScrollView.<init> (ScrollView.java:172)
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:288)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2196)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6696)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2628)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)
我同樣的問題。這是我的佈局中的隨機TextView導致它。沒有什麼不同或特別的。你有沒有找到解決辦法? – ono
不,我沒有。但是我把'setTheme(R.style.AppTheme);''super.onCreate(savedInstanceState)''之前'變好了''根據這個文件https://developer.android.com/topic/performance/launch-time。 HTML。 –