Я новичок в android и firebase. У меня есть настройка проекта в firebase и подключена. Я знаю, что у меня должны быть некоторые ошибки кода, которые мешают моим пользователям подключиться к firebase. Приложение запускается нормально, и работает AlertDialog. Проблема заключается в том, что я вводил адрес электронной почты, имя пользователя и пароль. То, когда приложение падает, и я не вижу, чтобы пользователи добавили в firebase. Любая помощь будет оценена по достоинству. Пожалуйста, дружелюбный к нору, потому что я просто учился.Настройка входа пользователя с Firebase
public class CreateAccount extends AppCompatActivity implements ProgressGenerator.OnCompleteListener {
private EditText emailAddress;
// private EditText userName;
private EditText password;
private String userId;
private ProgressGenerator progressGenerator;
private ActionProcessButton createAccountButton;
public CreateAccount() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_account);
emailAddress = (EditText) findViewById(R.id.userEmailId);
password = (EditText) findViewById(R.id.userNamePasswordId);
//userName = (EditText) findViewById(R.id.userNameAccountId);
progressGenerator = new ProgressGenerator(this);
createAccountButton = (ActionProcessButton) findViewById(R.id.userNameCreateAccountButtonId);
createAccountButton.setMode(ActionProcessButton.Mode.PROGRESS);
createAccountButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setCreateAccount();
}
});
}
private void setCreateAccount() {
final String uEmail = emailAddress.getText().toString();
//final String uName = userName.getText().toString();
final String uPword = password.getText().toString();
if (uEmail.equals("") || uPword.equals("")) {
final AlertDialog.Builder dialog = new AlertDialog.Builder(CreateAccount.this);
dialog.setTitle("Empty Field");
dialog.setMessage("Please Complete All Fields");
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
} else {
final Firebase ref = new Firebase("https://texter-20d04.firebaseio.com/");
progressGenerator.start(createAccountButton);
createAccountButton.setEnabled(false);
emailAddress.setEnabled(false);
password.setEnabled(false);
ref.createUser(uEmail, uPword, new Firebase.ValueResultHandler<Map<String, Object>>() {
@Override
public void onSuccess(Map<String, Object> result) {
logUserIn(uEmail, uPword, ref);
//create a new branch with username
}
@Override
public void onError(FirebaseError firebaseError) {
// there was an error
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
});
}
}
private void logUserIn(final String uEmail, final String uPword, final Firebase ref) {
if (!uEmail.equals("") || !uPword.equals("")) {
ref.authWithPassword(uEmail, uPword, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
userId = authData.getUid();
Log.v("USER ID: ", userId);
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
}
});
}
}
@Override
public void onComplete() {
startActivity(new Intent(CreateAccount.this, ChatActivity.class));
}
}
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "texter.rednak71.com.texter"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-core:9.0.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.firebase:firebase-crash:9.8.0'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Мне удалось получить логин, регистрацию и забыли пароль, сделанные за 20 минут благодаря этому учебному пособию: http://www.androidhive.info/2016/06/android-getting-started-firebase-simple-login-registration- авт / –