我在Play商店中放置了一個應用程序,並且收到崩潰報告,說明我很難重現。無法在某些設備上啓動android活動
它來自運行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
文件。它是否這樣做?
我發現這個資源可能是有用的:http://stackoverflow.com/questions/2605999/android-how-to-track-down-the-origin-of-a-inflateexception?lq=1 – mariosangiorgio