It seems that I can create 1 activity perfectly, however starting a new one causes a crash.
LoginActivity:
@BindView(R.id.input_username)
EditText _usernameText;
@BindView(R.id.register_button)
TextView register_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
register_button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent(getApplication(), RegisterActivity.class);
startActivity(intent);
}
});
}
And my register activity:
@BindView(R.id.input_username_register)
EditText _usernameText;
@BindView(R.id.input_email_register)
EditText _emailText;
@BindView(R.id.input_password_register)
EditText _passwordText;
@BindView(R.id.login_button_register)
Button login_button;
@BindView(R.id.register_button_register)
TextView register_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ButterKnife.setDebug(true);
ButterKnife.bind(this);
Injector.inject(this);
register_button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
register();
}
});
login_button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent(getApplication(), LoginActivity.class);
startActivity(intent);
}
});
}
Log:
6-16 16:41:59.863 1293-1293/com.mattikettu.pinkiponki D/ButterKnife: Looking up view binder for com.mattikettu.pinkiponki.RegisterActivity
06-16 16:41:59.864 1293-1293/com.mattikettu.pinkiponki D/ButterKnife: HIT: Loaded view binder class.
06-16 16:41:59.866 1293-1293/com.mattikettu.pinkiponki D/AndroidRuntime: Shutting down VM
06-16 16:41:59.868 1293-1293/com.mattikettu.pinkiponki E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mattikettu.pinkiponki, PID: 1293
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mattikettu.pinkiponki/com.mattikettu.pinkiponki.RegisterActivity}: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.app.Activity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.app.Activity
at butterknife.internal.Finder$2.getContext(Finder.java:34)
at butterknife.internal.Finder.getResourceEntryName(Finder.java:131)
at butterknife.internal.Finder.findRequiredViewAsType(Finder.java:86)
at com.mattikettu.pinkiponki.RegisterActivity$$ViewBinder$InnerUnbinder.<init>(RegisterActivity$$ViewBinder.java:29)
at com.mattikettu.pinkiponki.RegisterActivity$$ViewBinder.bind(RegisterActivity$$ViewBinder.java:17)
at com.mattikettu.pinkiponki.RegisterActivity$$ViewBinder.bind(RegisterActivity$$ViewBinder.java:14)
at butterknife.ButterKnife.bind(ButterKnife.java:122)
at com.mattikettu.pinkiponki.RegisterActivity.onCreate(RegisterActivity.java:46)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)聽
at android.app.ActivityThread.-wrap11(ActivityThread.java)聽
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)聽
at android.os.Handler.dispatchMessage(Handler.java:102)聽
at android.os.Looper.loop(Looper.java:148)聽
at android.app.ActivityThread.main(ActivityThread.java:5422)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)聽
General code can be found: https://github.com/mathieudevos/pinkiponki-app
I have solved the issue myself, I messed up between the Button and TextView with the @BindView
This caused a failed cast, which crashed everything. Debugging it was a bit weird, as the line debugger wasn't that helpful at all. But fixed it now!
Most helpful comment
I have solved the issue myself, I messed up between the Button and TextView with the @BindView
This caused a failed cast, which crashed everything. Debugging it was a bit weird, as the line debugger wasn't that helpful at all. But fixed it now!