使用移动数据在Android上使用Firebase身份验证时,我在运行应用时遇到以下错误:
com.google.firebase.FirebaseException: An internal error has occured. [ Internal error. ]
at com.google.android.gms.internal.zzacq.zzbN(Unknown Source)
at com.google.android.gms.internal.zzacn$zzg.zza(Unknown Source)
at com.google.android.gms.internal.zzacy.zzbO(Unknown Source)
at com.google.android.gms.internal.zzacy$zza.onFailure(Unknown Source)
at com.google.android.gms.internal.zzact$zza.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:412)
at dalvik.system.NativeStart.run(Native Method)
但是,当我运行相同的应用使用wifi 时,会显示没有错误并且身份验证正常发生而没有任何错误,并显示以下消息而不是上述错误:
Considering local module com.google.android.gms.firebase_database:2 and remote module com.google.android.gms.firebase_database:2
Selected remote version of com.google.android.gms.firebase_database, version >= 2
我用来验证/创建用户的代码如下:
mAuth.createUserWithEmailAndPassword(emailSignup, passwordSignup)
.addOnCompleteListener(LogInSignUp.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
// 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.
if (!task.isSuccessful())
{
Toast.makeText(LogInSignUp.this, "Authentication failed.",Toast.LENGTH_SHORT).show();
task.getException().printStackTrace();
dialogLoading.cancel();
}
else
{
String clientUID=mAuth.getCurrentUser().getUid();
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference user = database.getReference("clients");
user.push();
ClientProfile c=new ClientProfile();
c.setEmail(emailSignup);
c.setName(nameSignup);
c.setPassword(passwordSignup);
user.child(clientUID).setValue(c);
}
}
});
我正在使用
compile 'com.google.firebase:firebase-auth:9.0.2'
在清单文件中:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>