我的應用程序出於某些不可解釋的原因正在HTC Desire HD上崩潰。它在其他手機以及模擬器中工作正常。這是崩潰報告:Desire HD中的應用程序崩潰
"java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.HomeActivity}: android.view.InflateException: Binary XML file line #30: Error inflating class android.widget.EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2833)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2854)
at android.app.ActivityThread.access$2300(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5068)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class android.widget.EditText
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.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
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:215)
at android.app.Activity.setContentView(Activity.java:1686)
at com.myapp.HomeActivity.onCreate(HomeActivity.java:165)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2797)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:53)
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)
... 26 more
Caused by: java.lang.NullPointerException
at com.htc.textselection.TextSelectionMethodImpl.initAnchorAndMagnifier(TextSelectionMethodImpl.java:300)
at com.htc.textselection.TextSelectionMethodImpl.initialize(TextSelectionMethodImpl.java:287)
at android.widget.TextView.setText(TextView.java:2712)
at android.widget.TextView.setText(TextView.java:2590)
at android.widget.EditText.setText(EditText.java:84)
at android.widget.TextView.setText(TextView.java:2565)
at android.widget.TextView.setTransformationMethod(TextView.java:1209)
at android.widget.TextView.applySingleLine(TextView.java:6024)
at android.widget.TextView.setSingleLine(TextView.java:6015)
at android.widget.TextView.setSingleLine(TextView.java:5992)
at android.widget.TextView.<init>(TextView.java:863)
at android.widget.EditText.<init>(EditText.java:57)
... 30 more
android.view.InflateException: Binary XML file line #30: Error inflating class android.widget.EditText
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.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
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:215)
at android.app.Activity.setContentView(Activity.java:1686)
at com.myapp.HomeActivity.onCreate(HomeActivity.java:165)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2797)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2854)
at android.app.ActivityThread.access$2300(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5068)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:53)
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)
... 26 more
Caused by: java.lang.NullPointerException
at com.htc.textselection.TextSelectionMethodImpl.initAnchorAndMagnifier(TextSelectionMethodImpl.java:300)
at com.htc.textselection.TextSelectionMethodImpl.initialize(TextSelectionMethodImpl.java:287)
at android.widget.TextView.setText(TextView.java:2712)
at android.widget.TextView.setText(TextView.java:2590)
at android.widget.EditText.setText(EditText.java:84)
at android.widget.TextView.setText(TextView.java:2565)
at android.widget.TextView.setTransformationMethod(TextView.java:1209)
at android.widget.TextView.applySingleLine(TextView.java:6024)
at android.widget.TextView.setSingleLine(TextView.java:6015)
at android.widget.TextView.setSingleLine(TextView.java:5992)
at android.widget.TextView.<init>(TextView.java:863)
at android.widget.EditText.<init>(EditText.java:57)
... 30 more
java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:53)
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)
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.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
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:215)
at android.app.Activity.setContentView(Activity.java:1686)
at com.myapp.HomeActivity.onCreate(HomeActivity.java:165)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2797)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2854)
at android.app.ActivityThread.access$2300(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5068)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.htc.textselection.TextSelectionMethodImpl.initAnchorAndMagnifier(TextSelectionMethodImpl.java:300)
at com.htc.textselection.TextSelectionMethodImpl.initialize(TextSelectionMethodImpl.java:287)
at android.widget.TextView.setText(TextView.java:2712)
at android.widget.TextView.setText(TextView.java:2590)
at android.widget.EditText.setText(EditText.java:84)
at android.widget.TextView.setText(TextView.java:2565)
at android.widget.TextView.setTransformationMethod(TextView.java:1209)
at android.widget.TextView.applySingleLine(TextView.java:6024)
at android.widget.TextView.setSingleLine(TextView.java:6015)
at android.widget.TextView.setSingleLine(TextView.java:5992)
at android.widget.TextView.<init>(TextView.java:863)
at android.widget.EditText.<init>(EditText.java:57)
... 30 more
java.lang.NullPointerException
at com.htc.textselection.TextSelectionMethodImpl.initAnchorAndMagnifier(TextSelectionMethodImpl.java:300)
at com.htc.textselection.TextSelectionMethodImpl.initialize(TextSelectionMethodImpl.java:287)
at android.widget.TextView.setText(TextView.java:2712)
at android.widget.TextView.setText(TextView.java:2590)
at android.widget.EditText.setText(EditText.java:84)
at android.widget.TextView.setText(TextView.java:2565)
at android.widget.TextView.setTransformationMethod(TextView.java:1209)
at android.widget.TextView.applySingleLine(TextView.java:6024)
at android.widget.TextView.setSingleLine(TextView.java:6015)
at android.widget.TextView.setSingleLine(TextView.java:5992)
at android.widget.TextView.<init>(TextView.java:863)
at android.widget.EditText.<init>(EditText.java:57)
at android.widget.EditText.<init>(EditText.java:53)
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)
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.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
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:215)
at android.app.Activity.setContentView(Activity.java:1686)
at com.myapp.HomeActivity.onCreate(HomeActivity.java:165)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2797)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2854)
at android.app.ActivityThread.access$2300(ActivityThread.java:136)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5068)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
"
當爲EditText設置一個值時,崩潰似乎正在發生。這裏是XML中的EditText字段:
<EditText style="@style/HomeInput" android:id="@+id/signin_username"
android:capitalize="none"
android:imeOptions="actionDone"
android:inputType="text"
android:text=""
android:maxLines="1"/>
XML有什麼問題嗎?如果是的話,爲什麼它在模擬器或其他手機中工作?
編輯1
這裏是樣式XML
<style name="HomeInput">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">@dimen/text_size_small</item>
<item name="android:textColor">@color/signin_input</item>
<item name="android:layout_marginTop">10dip</item>
<item name="android:layout_marginBottom">5dip</item>
<item name="android:layout_marginLeft">10dip</item>
<item name="android:layout_marginRight">10dip</item>
</style>
編輯2
編輯3
該應用使用從xml/preferences.xml膨脹的EditTextPreference崩潰。這裏是崩潰報告:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vtcreator.android360/com.myapp.SettingsActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class java.lang.reflect.Constructor
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2852)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$2300(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2186)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5127)
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 #19: Error inflating class java.lang.reflect.Constructor
at android.preference.GenericInflater.createItem(GenericInflater.java:397)
at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:254)
at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:268)
at com.myapp.SettingsActivity.onCreate(SettingsActivity.java:39)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2816)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.preference.EditTextPreference.<init>(EditTextPreference.java:71)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.preference.GenericInflater.createItem(GenericInflater.java:383)
... 22 more
Caused by: java.lang.NullPointerException
at com.htc.quickselection.HtcQuickSelectionWindow.<init>(HtcQuickSelectionWindow.java:164)
at com.htc.textselection.TextSelectionMethodImpl.initAnchorAndMagnifier(TextSelectionMethodImpl.java:326)
at com.htc.textselection.TextSelectionMethodImpl.initialize(TextSelectionMethodImpl.java:297)
at android.widget.TextView.setText(TextView.java:2746)
at android.widget.TextView.setText(TextView.java:2626)
at android.widget.EditText.setText(EditText.java:82)
at android.widget.TextView.<init>(TextView.java:924)
at android.widget.EditText.<init>(EditText.java:57)
at android.widget.EditText.<init>(EditText.java:53)
at android.preference.EditTextPreference.<init>(EditTextPreference.java:56)
... 26 more
看起來像HTC固件中的錯誤。一旦我與三星有類似的情況,在'PopupWindow'上的'EditText'(該錯誤不會在HTC和仿真器上重現)。 – ernazm 2011-03-31 13:48:15
可能是一個明顯的問題,但這裏涉及的不同API級別有哪些? – RivieraKid 2011-03-31 14:00:03
只需在Android 2.2(API級別8)上進行測試即可。相同的代碼在仿真器上工作> 2.3。 – Abhinav 2011-03-31 14:04:02