我没有太多信息可提供,因为我不知道问题出在哪里。当我在模拟器上运行它时,它工作得很好,但是当我尝试在设备上运行它时,我无法通过登录/注册。这是我的登录代码,非常简单,注册几乎相同,因此我不会费心张贴它:
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
login_button.setOnClickListener {
performLogin()
}
}
fun backToRegistration (view : View) {
val registerIntent = Intent (this, RegisterActivity::class.java)
startActivity(registerIntent)
}
private fun performLogin(){
val logEmail = login_email.text.toString()
val logPass = login_password.text.toString()
Log.d("Main", "email is $logEmail")
Log.d("Main", "pass is $logPass")
// Patterns.EMAIL_ADDRESS.matcher(logEmail).matches() <--- this method was used before for the if statement but I've replaced it as I kept getting the invalid email error for some reason.
if (logEmail.contains("@") && logEmail.contains(".")) {
if (logPass.length > 5) {
FirebaseAuth.getInstance().signInWithEmailAndPassword(logEmail, logPass).addOnCompleteListener {
if (it.isSuccessful) {
Log.d("Login", "Successfully logged a user in using uid: ${it.result?.user?.uid}")
val intent = Intent(this, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK.or(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
return@addOnCompleteListener
}
//else if successful
Log.d("Login", "Failed to log in a user")
}.addOnFailureListener {
Log.d("Main", "Failed to create user : ${it.message}")
}
} else {
Toast.makeText(this, "Your password needs to be at least 6 characters long", Toast.LENGTH_LONG)
.show()
}
} else {
Toast.makeText(this, "Please enter a valid email address", Toast.LENGTH_LONG).show()
}
}
}
这是我尝试登录后立即登录的日志(级别设置为错误):
2019-03-12 17:23:56.496 730-17078/? E/voice: voice_is_in_call:in_call 0
2019-03-12 17:23:56.496 730-17078/? E/voice: voice_is_in_call:in_call 0
2019-03-12 17:23:56.496 730-17078/? E/voice: voice_is_in_call:in_call 0
2019-03-12 17:23:56.497 730-17078/? E/msm8974_platform: platform_check_backends_match: Invalid snd_device =
2019-03-12 17:23:56.497 730-17078/? E/soundtrigger: audio_extn_sound_trigger_update_stream_status: invalid input device 0x0, for event 3
2019-03-12 17:23:57.290 3268-12575/? E/Volley: [2631] BasicNetwork.performRequest: Unexpected response code 400 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?alt=proto&key=AIzaSyDVSMXQ9fymqlaJiaDogQt7i6-5j3xUbmY
2019-03-12 17:23:57.370 884-1070/? E/libc: Access denied finding property "sys.thermal.para"
2019-03-12 17:23:58.028 912-976/? E/storaged: getDiskStats failed with result NOT_SUPPORTED and size 0
2019-03-12 17:23:59.683 730-5610/? E/soundtrigger: audio_extn_sound_trigger_update_stream_status: invalid input device 0x0, for event 2
2019-03-12 17:24:02.371 884-1070/? E/libc: Access denied finding property "sys.thermal.para"
2019-03-12 17:24:07.379 884-1070/? E/libc: Access denied finding property "sys.thermal.para"
2019-03-12 17:24:12.380 884-1070/? E/libc: Access denied finding property "sys.thermal.para"