gpt4 book ai didi

java - 运行后应用程序在模拟器中关闭

转载 作者:行者123 更新时间:2023-12-01 17:54:18 24 4
gpt4 key购买 nike

每次我尝试运行应用程序时,应用程序都会在加载 Activity 后停止。当它尝试运行 MainActivity 时,它会停止。我的 logcat 看起来像这样。

03-18 20:41:11.242 11729-11729/com.example.valueapp D/AndroidRuntime: Shutting down VM
03-18 20:41:11.243 11729-11729/com.example.valueapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.valueapp, PID: 11729
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.valueapp/com.example.valueapp.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatSpinner cannot be cast to android.widget.EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatSpinner cannot be cast to android.widget.EditText
at com.example.valueapp.MainActivity.onCreate(MainActivity.java:27)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

最佳答案

尝试项目 -> 清理

如果这不起作用,您实际上可能会将某些内容转换到 EditText 的某处。

关于java - 运行后应用程序在模拟器中关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60746522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com