[英]app works perfectly fine on the emulator but when running on my device it doesn't login/register
I don't have much information to provide as I have no idea what the problem is. 我没有太多信息可提供,因为我不知道问题出在哪里。 It works just fine when I run it on the emulator but when I try to run it on my device I can't get past the login/register.
当我在模拟器上运行它时,它工作得很好,但是当我尝试在设备上运行它时,我无法通过登录/注册。 This is my login code, pretty straight forward and the register is pretty much the same so I won't bother to post it:
这是我的登录代码,非常简单,注册几乎相同,因此我不会费心发布它:
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()
}
}
}
This is my logcat (level set to error) right after I attempt a login: 尝试登录后,这是我的logcat(级别设置为error):
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"
To anyone facing the same issue here are two possible solutions, based on your situation. 对于面临相同问题的任何人,根据您的情况,这里有两种可能的解决方案。
If your app is on the app store and you're having that issue, refer to the answer posted here Thank you @Swati for referring it to me. 如果您的应用程序在应用程序商店中,而您遇到该问题,请参考此处发布的答案。感谢@Swati将其推荐给我。
If you are just trying to run it on your phone for testing and, make sure that you've provided the SHA certificate fingerprints in your Firebase project. 如果您只是想在手机上运行它进行测试,请确保在Firebase项目中提供了SHA证书指纹。 If you're not sure what that means, go to your project settings -> General and SHA certificate fingerprints should be under "Your apps".
如果不确定这意味着什么,请转至项目设置->常规和SHA证书指纹应位于“您的应用”下。
You will need to enter both SHA-1 & SHA-256 您将需要同时输入SHA-1和SHA-256
To get them go to your Android project and click the "Gradle" tab on the almost-top right corner of the window (using windows, not sure about mac). 要获取它们,请转到您的Android项目,然后单击窗口几乎右上角的“ Gradle”选项卡(使用Windows,不确定mac)。
Then navigate to your project -> :app -> Tasks -> android and double click the "signingReport". 然后导航到您的项目->:app-> Tasks-> android,然后双击“ signingReport”。
It should run some lines at the bottom of your window where your log cat is usually and in them you would find both SHA-1 and SHA-256 它应该在您的日志猫通常所在的窗口的底部运行一些行,在其中您会发现SHA-1和SHA-256
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.