2012-02-21 96 views
1

我正在開發一個android應用程序,當我點擊運行後,我解鎖AVD並單擊菜單加載我的應用程序,然後立即收到「應用程序意外關閉」消息。Android應用程序在開啓後立即崩潰

以下是我的logcat輸出:

02-21 11:36:55.952: D/AndroidRuntime(329): Shutting down VM 
02-21 11:36:55.952: W/dalvikvm(329): threadid=1: thread exiting with uncaughtexception (group=0x40015560) 
02-21 11:36:55.971: E/AndroidRuntime(329): FATAL EXCEPTION: main 
02-21 11:36:55.971: E/AndroidRuntime(329): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.throughputconverter/com.throughputconverter.ThroughputConverterActivity}: java.lang.ClassCastException: android.widget.EditText 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.os.Handler.dispatchMessage(Handler.java:99) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.os.Looper.loop(Looper.java:123) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.ActivityThread.main(ActivityThread.java:3683) 
02-21 11:36:55.971: E/AndroidRuntime(329): at java.lang.reflect.Method.invokeNative(Native Method) 
02-21 11:36:55.971: E/AndroidRuntime(329): at java.lang.reflect.Method.invoke(Method.java:507) 
02-21 11:36:55.971: E/AndroidRuntime(329): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
02-21 11:36:55.971: E/AndroidRuntime(329): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
02-21 11:36:55.971: E/AndroidRuntime(329): at dalvik.system.NativeStart.main(Native Method) 
02-21 11:36:55.971: E/AndroidRuntime(329): Caused by: java.lang.ClassCastException: android.widget.EditText 
02-21 11:36:55.971: E/AndroidRuntime(329): at com.throughputconverter.ThroughputConverterActivity.onCreate(ThroughputConverterActivity.java:44) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
02-21 11:36:55.971: E/AndroidRuntime(329): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 
02-21 11:36:55.971: E/AndroidRuntime(329): ... 11 more 
+2

你能否將第44行粘貼到ThroughputConverterActivity.java中 – PravinCG 2012-02-21 16:44:32

+0

粘貼你的代碼?如果我可以看到整個事情,它會更容易,但我可以推測它有一些事情: 引起:java.lang.ClassCastException:android.widget.EditText – 2012-02-21 16:45:52

+0

其實,通過檢查,我發現我遇到的問題。我有兩個小工具叫同樣的事情,它搞砸了。謝謝你的幫助 – Parth 2012-02-21 16:48:03

回答

2

看起來您錯誤地投射了EditText小部件,或者您的佈局和/或Activity中不存在小部件。

2

似乎你投對象的EditText,但這個對象就是這種不:

java.lang.ClassCastException: android.widget.EditText 

你能提供線44 ?

0

我曾面臨同樣的錯誤

搜索一切爲了事業 什麼也沒有我的情況 工作然後仔細打量到資源XML,

我改變了最近添加的元素

<Button android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/bClick2" 
android:background="@drawable/new1" 
android:layout_gravity="bottom"> 
</Button> 

<Button android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/bClick2" 
android:background="@drawable/new1" 
android:layout_gravity="bottom"/> 

和我的問題解決了。