我的Android应用程序说不幸的是,只要我点击了我想从LoginActivity转移到RegisterActivity的注册表按钮,androidAppName就停止了响应
以下是Logcat错误消息:
03-03 03:41:02.541 1473-32321/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -m 31808 -o /data/log/dumpstate_app_error
这是我的activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context="com.geekbounty.nigerianscholars.LoginActivity"
android:background="#555d7b"
>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="170dp"
android:layout_marginBottom="20dp"
android:background="#FF00FF"
android:id="@+id/etUsername"
android:hint="Email Address"
android:paddingLeft="12dp"
android:maxLines="1"
android:inputType="textEmailAddress"/>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@+id/etUsername"
android:background="#ff00ff"
android:hint="Password"
android:paddingLeft="12dp"
android:id="@+id/etPassword"
android:inputType="textPassword"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:textColor="#ffffff"
android:layout_below="@id/etPassword"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:onClick="forgotPasswordHandler"
android:layout_marginBottom="5dp"
android:id="@+id/tvFPassword"/>
<Button
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/btnLogin"
android:text="login"
android:background="#44ddee"
android:layout_below="@id/tvFPassword"
android:layout_marginBottom="10dp"
android:onClick="loginHandler"/>
<TextView
android:id="@+id/tvSignup"
android:layout_below="@id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register"
android:textSize="20sp"
android:textColor="#44ddee"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:onClick="signupHandler"/>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_below="@id/tvSignup"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:visibility="invisible"/>
</RelativeLayout>
这也是我的LoginActivity.java
package com.geekbounty.nigerianscholars;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class LoginActivity extends AppCompatActivity {
private EditText inputUsername, inputPassword;
private TextView forgotPassword, signup;
private Button login;
private FirebaseAuth auth;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
//Get Firebase auth instance
auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
startActivity(new Intent(LoginActivity.this, HomeActivity.class));
finish();
}
inputUsername = (EditText) findViewById(R.id.etUsername);
inputPassword = (EditText) findViewById(R.id.etPassword);
forgotPassword = (TextView) findViewById(R.id.tvFPassword);
signup = (TextView) findViewById(R.id.tvSignup);
login = (Button) findViewById(R.id.btnLogin);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
//Get Firebase auth instance
auth = FirebaseAuth.getInstance();
}
public void signuHandler(View view) {
startActivity(new Intent(this, RegisterActivity.class));
}
public void forgotPasswordHandler(View view) {
startActivity(new Intent(this, ResetPasswordActivity.class));
}
public void loginHandler(View view) {
String email = inputUsername.getText().toString().trim();
final String password = inputPassword.getText().toString().trim();
if (TextUtils.isEmpty(email)) {
Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show();
return;
}
if(TextUtils.isEmpty(password)) {
Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show();
return;
}
progressBar.setVisibility(View.VISIBLE);
//authenticate user
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
progressBar.setVisibility(View.GONE);
if (!task.isSuccessful()) {
// there was an error
if (password.length() < 6) {
inputPassword.setError(getString(R.string.minimum_password));
} else {
Toast.makeText(LoginActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show();
}
} else {
Intent intent = new
Intent(LoginActivity.this, HomeActivity.class);
startActivity(intent
finish();
}
}
});
}
}
这是我的Stacktrace
03-03 03:41:02.541 1473-32321/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -m 31808 -o /data/log/dumpstate_app_error
03-03 03:48:29.317 4908-4908/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
03-03 03:48:29.317 4908-4908/? D/FA: Debug logging enabled
03-03 03:55:39.807 5120-5120/? I/GAv4: Google Analytics 7.5.71 is starting up. To enable debug logging on a device run:
adb shell setprop log.tag.GAv4 DEBUG
adb logcat -s GAv4
03-03 03:57:31.716 5446-5446/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
03-03 03:57:31.716 5446-5446/? D/FA: Debug logging enabled
03-03 03:57:40.204 5625-5625/? I/AS.: 03:57:40.208[1] Logger Started, DebugVersion = false
03-03 04:01:27.956 5942-5985/? I/dalvikvm: Could not find method android.os.Debug.startMethodTracingSampling, referenced from method com.facebook.trace.DebugTracer.a
03-03 04:01:27.956 5942-5985/? W/dalvikvm: VFY: unable to resolve static method 723: Landroid/os/Debug;.startMethodTracingSampling (Ljava/lang/String;II)V
03-03 04:01:32.451 6129-6129/? I/AS.: 04:01:32.464[1] Logger Started, DebugVersion = false
03-03 04:03:31.837 6417-6417/? I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
03-03 04:03:31.837 6417-6417/? D/FA: Debug logging enabled
03-03 04:13:30.461 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:30.491 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:30.862 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:30.872 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:31.062 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:31.082 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:32.253 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:32.263 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:32.443 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:32.453 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:35.997 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:36.007 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:37.919 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:37.929 1769-1769/? I/SamsungIME: getDebugLevel : 0x4f4c
03-03 04:13:43.334 6680-6680/com.geekbounty.nigerianscholars I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
03-03 04:13:43.374 6680-6680/com.geekbounty.nigerianscholars I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.geekbounty.nigerianscholars
03-03 04:13:43.374 6680-6680/com.geekbounty.nigerianscholars D/FA: Debug-level message logging enabled
03-03 04:13:43.634 6680-6680/com.geekbounty.nigerianscholars D/OpenGLRenderer: Enabling debug mode 0
03-03 04:13:46.207 1473-6758/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -m 6680 -o /data/log/dumpstate_app_error
03-03 04:14:18.668 7267-7306/? I/dalvikvm: Could not find method android.os.Debug.startMethodTracingSampling, referenced from method com.facebook.trace.DebugTracer.a
03-03 04:14:18.668 7267-7306/? W/dalvikvm: VFY: unable to resolve static method 723: Landroid/os/Debug;.startMethodTracingSampling (Ljava/lang/String;II)V
03-03 04:25:21.515 11430-11430/? E/android.os.Debug: failed to load memtrack module: -2
03-03 04:25:22.646 11445-11445/? E/android.os.Debug: failed to load memtrack module: -2
03-03 04:25:33.156 11468-11468/? E/android.os.Debug: failed to load memtrack module: -2
03-03 04:25:42.606 11531-11531/? E/android.os.Debug: failed to load memtrack module: -2
03-03 04:25:44.247 11560-11560/com.geekbounty.nigerianscholars I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
03-03 04:25:44.497 11560-11560/com.geekbounty.nigerianscholars I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.geekbounty.nigerianscholars
03-03 04:25:44.497 11560-11560/com.geekbounty.nigerianscholars D/FA: Debug-level message logging enabled
03-03 04:25:44.968 11560-11560/com.geekbounty.nigerianscholars D/OpenGLRenderer: Enabling debug mode 0
03-03 04:25:47.470 11668-11695/? I/GAv4: Google Analytics 8.4.87 is starting up. To enable debug logging on a device run:
adb shell setprop log.tag.GAv4 DEBUG
adb logcat -s GAv4
03-03 04:25:48.551 11738-11738/? I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
03-03 04:25:51.484 11845-11845/? E/android.os.Debug: failed to load memtrack module: -2
03-03 04:25:52.755 11820-11820/? I/dalvikvm: Could not find method android.os.Debug.startMethodTracingSampling, referenced from method com.facebook.trace.DebugTracer.a
03-03 04:25:52.755 11820-11820/? W/dalvikvm: VFY: unable to resolve static method 723: Landroid/os/Debug;.startMethodTracingSampling (Ljava/lang/String;II)V
03-03 04:25:59.973 12069-12069/? I/GAv4: Google Analytics 7.5.71 is starting up. To enable debug logging on a device run:
adb shell setprop log.tag.GAv4 DEBUG
adb logcat -s GAv4
03-03 04:26:07.690 1473-12355/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -m 11560 -o /data/log/dumpstate_app_error
答案 0 :(得分:0)
好的,我刚发现你的问题。方法名称上只有一个拼写错误。改变
public void signuHandler(View view) {
startActivity(new Intent(this, RegisterActivity.class));
}
到
public void signupHandler(View view) {
startActivity(new Intent(this, RegisterActivity.class));
}