-1

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?

migueldeo
  • 3
  • 2

3 Answers3

1

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

Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
  • Hmm, it seems that is the problem because it doesnt crash when I completely removed the code, but I was unable to resolve it. When I change the inputEmail = (TextInputLayout) findViewById(R.id.input_log_email); line to (TextInputEditText), I got an error. – migueldeo Nov 05 '17 at 17:45
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.

Kulebin
  • 246
  • 1
  • 8
  • Err, do you mind pointing out? I can't seem to find the problem. Thanks a lot. – migueldeo Nov 05 '17 at 18:47
  • @migueldeo look, you are trying to cast your TextInputEditText view to TextInputLayout by(TextInputLayout) findViewById(R.id.input_log_email); you should change it to (TextInputEditText) findViewById(R.id.input_log_email); and change the type of your variables private TextInputLayout inputEmail, inputPass; – Kulebin Nov 05 '17 at 19:01
0

private TextInputEditText inputEmail, inputPass;

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

AYUSH ARYA
  • 123
  • 8