我在尝试运行我的应用程序时遇到了一些错误这里是 logcat
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.chatapp/com.example.chatapp.MainActivity}: java.lang.InstantiationException: java.lang.Class<com.example.chatapp.MainActivity> has no zero argument constructor
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2843)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.InstantiationException: java.lang.Class<com.example.chatapp.MainActivity> has no zero argument constructor
这是我的 mainAcivity `public class MainActivity extends AppCompatActivity {
Button login, register;
FirebaseUser firebaseUser;
@Override
protected void onStart() {
super.onStart();
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
//check if user in null
if (firebaseUser != null){
Intent intent = new Intent(MainActivity.this, Main2Activity.class);
new MainActivity(intent);
finish();
}
}
`
但我也认为这是一个错误
public MainActivity(Intent intent) {
}
眼眸繁星
相关分类