我目前正在开发一个 Android 应用程序,虽然在 Jelly Bean 模拟器上一切正常,但在 2.2 模拟器上出现以下错误:
10-11 22:26:35.853: E/AndroidRuntime(303): FATAL EXCEPTION: main
10-11 22:26:35.853: E/AndroidRuntime(303): android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
10-11 22:26:35.853: E/AndroidRuntime(303): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
10-11 22:26:35.853: E/AndroidRuntime(303): at com.android.iagrams.util.MyAdapter.getView(MyAapter.java:20)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.ListView.makeAndAddView(ListView.java:1727)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.ListView.fillDown(ListView.java:652)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.ListView.fillFromTop(ListView.java:709)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.ListView.layoutChildren(ListView.java:1580)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.layout(View.java:7035)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.layout(View.java:7035)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.layout(View.java:7035)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.layout(View.java:7035)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.layout(View.java:7035)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.os.Looper.loop(Looper.java:123)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-11 22:26:35.853: E/AndroidRuntime(303): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 22:26:35.853: E/AndroidRuntime(303): at java.lang.reflect.Method.invoke(Method.java:521)
10-11 22:26:35.853: E/AndroidRuntime(303): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-11 22:26:35.853: E/AndroidRuntime(303): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-11 22:26:35.853: E/AndroidRuntime(303): at dalvik.system.NativeStart.main(Native Method)
10-11 22:26:35.853: E/AndroidRuntime(303): Caused by: java.lang.reflect.InvocationTargetException
10-11 22:26:35.853: E/AndroidRuntime(303): at android.widget.LinearLayout.<init>(LinearLayout.java:115)
10-11 22:26:35.853: E/AndroidRuntime(303): at java.lang.reflect.Constructor.constructNative(Native Method)
10-11 22:26:35.853: E/AndroidRuntime(303): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
10-11 22:26:35.853: E/AndroidRuntime(303): ... 36 more
10-11 22:26:35.853: E/AndroidRuntime(303): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
10-11 22:26:35.853: E/AndroidRuntime(303): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.<init>(View.java:2036)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.View.<init>(View.java:1834)
10-11 22:26:35.853: E/AndroidRuntime(303): at android.view.ViewGroup.<init>(ViewGroup.java:285)
10-11 22:26:35.853: E/AndroidRuntime(303): ... 40 more
据我所知,我没有使用任何 Jelly Bean 特定功能,也不知道我遇到了什么错误。我确实有一个自定义适配器,但我没有做太多,我只更改了几个文本视图。