问题
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