My app crashes when I try to navigate, can't seem to find issue

本小妞迷上赌 提交于 2021-02-05 12:17:36

问题


I can't seem to find whats wrong with my application... Here is the logcat:

11-05 16:37:30.030 7867-7867/com.capstone.miguel.studentassistant E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.capstone.miguel.studentassistant, PID: 7867
                                                                                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.capstone.miguel.studentassistant/com.capstone.miguel.studentassistant.user_sign.LoginActivity}: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                                                                                    at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                    at android.os.Looper.loop(Looper.java:154)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                                                 Caused by: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout
                                                                                    at com.capstone.miguel.studentassistant.user_sign.LoginActivity.onCreate(LoginActivity.java:34)
                                                                                    at android.app.Activity.performCreate(Activity.java:6679)
                                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                                                                                    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                    at android.os.Looper.loop(Looper.java:154) 
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:6119) 
                                                                                    at java.lang.reflect.Method.invoke(Native Method) 
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

Any idea why the application crashes?


回答1:


It looks like you have wrong casting: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout

Check if you use the same types in xml and in your code, probably they are different.




回答2:


This line is the problem

Caused by: java.lang.ClassCastException: android.support.design.widget.TextInputEditText cannot be cast to android.support.design.widget.TextInputLayout

Check the declared types match those in the layout file




回答3:


private TextInputEditText inputEmail, inputPass;

inputEmail = (TextInputEditText) findViewById(R.id.input_log_email); inputPass = (TextInputEditText) findViewById(R.id.input_log_pass);



来源:https://stackoverflow.com/questions/47124081/my-app-crashes-when-i-try-to-navigate-cant-seem-to-find-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!