7

在我的项目中添加了ActionBarCompat+ NavDrawer,在 4.3 设备上运行很流畅,在 2.3 设备上我得到以下异常:

09-08 15:09:15.229: E/AndroidRuntime(2964): FATAL EXCEPTION: main
09-08 15:09:15.229: E/AndroidRuntime(2964): android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.AbsListView.obtainView(AbsListView.java:1582)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.ListView.makeAndAddView(ListView.java:1801)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.ListView.fillDown(ListView.java:724)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.ListView.fillFromTop(ListView.java:781)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.ListView.layoutChildren(ListView.java:1652)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.AbsListView.onLayout(AbsListView.java:1412)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.layout(View.java:7175)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:702)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.layout(View.java:7175)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.layout(View.java:7175)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.layout(View.java:7175)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.layout(View.java:7175)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.layout(View.java:7175)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1146)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1866)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.os.Looper.loop(Looper.java:130)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.app.ActivityThread.main(ActivityThread.java:3687)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at java.lang.reflect.Method.invokeNative(Native Method)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at java.lang.reflect.Method.invoke(Method.java:507)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at dalvik.system.NativeStart.main(Native Method)
09-08 15:09:15.229: E/AndroidRuntime(2964): Caused by: java.lang.reflect.InvocationTargetException
09-08 15:09:15.229: E/AndroidRuntime(2964):     at java.lang.reflect.Constructor.constructNative(Native Method)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
09-08 15:09:15.229: E/AndroidRuntime(2964):     ... 35 more
09-08 15:09:15.229: E/AndroidRuntime(2964): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.content.res.Resources.loadDrawable(Resources.java:1681)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.view.View.<init>(View.java:1951)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.TextView.<init>(TextView.java:389)
09-08 15:09:15.229: E/AndroidRuntime(2964):     at android.widget.TextView.<init>(TextView.java:382)
09-08 15:09:15.229: E/AndroidRuntime(2964):     ... 38 more

我已经根据手册使用正确的支持包等设置了所有内容......

任何想法 ?如何确定罪魁祸首 xml 文件?

4

1 回答 1

4

然后将 ActionBarCompat 添加到 google 的 Navigation Drawer 示例中,不要忘记将本机方法更改为 SupportMethods:getActionBar() -> getSupportActionBar()invalidateOptionsMenu() -> supportInvalidateOptionsMenu() ; ...

并从Drawer_list_item.xml和其他仅适用于 API 14+ 的属性“?android:attr/...”中删除

Gabriele Mariotti 编写的这个很棒的教程必须对您有所帮助。

于 2013-10-15T14:28:23.173 回答