我在Play商店发了一个应用程序,我收到了一份Crash报告,说我很难重现。
它来自运行Android 2.2的V858 (hwu8160)
设备。它引发的例外情况如下:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mariosangiorgio.FutsalCoach/com.mariosangiorgio.FutsalCoach.FutsalCoachActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
at android.app.Activity.setContentView(Activity.java:1647)
at com.mariosangiorgio.FutsalCoach.FutsalCoachActivity.onCreate(FutsalCoachActivity.java:89)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.TextView.<init>(TextView.java:352)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 22 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
at android.widget.TextView.<init>(TextView.java:677)
... 26 more
我设置了运行Android 2.2的模拟器,但我无法重现该问题。你有什么建议我应该找到错误的原因并修复它吗?
这就是我在第10行的活动布局文件中所拥有的:
<TextView
android:id="@+id/match_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="@string/default_time"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/bigClockFontSize"
android:singleLine="true" />
似乎由于某种原因设备未加载@dimen/bigClockFontSize
值。
我设法通过从res/values/dimens.xml
中删除值来触发模拟器中的错误。
出现错误的设备使用意大利语语言环境,设备屏幕较小。 我有以下资源文件:
values/dimens.xml
values/strings.xml
values/styles.xml
values-it/strings.xml
values-normal-hdpi/dimens.xml
values-normal-xxhdpi/dimens.xml
我假设设备应解析values/dimes.xml
文件。它会那样做吗?