简体   繁体   English

应用程序在模拟器上运行正常,但在我的设备上运行时无法登录/注册

[英]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. 对于面临相同问题的任何人,根据您的情况,这里有两种可能的解决方案。

  1. 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将其推荐给我。

  2. 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.

相关问题 在模拟器中,我的应用可以正常运行,但不能在真实设备中运行 - In emulator my app running fine but not in real device Toast在实际设备上不起作用,但在模拟器上可以正常工作 - Toast doesn't works on real device but works fine on emulator 在设备上运行时没有这样的表错误,但在模拟器上相同的代码工作正常 - No such table error when running on device but on emulator same code works fine SQLite数据库Android应用程序在模拟器中无法在我的设备中正常运行 - SQLite database Android app works fine in emulator not in my device 我的 flutter 应用程序在模拟器上完美地将文件上传到 firebase(启用了 vpn),但在我的 android 设备上没有这样做 - My flutter app uploads file to firebase perfectly on emulator(vpn enabled) but doesn't do so on my android device Android App 在模拟器中运行良好,但无法在真实设备中安装 - Android App running fine in Emulator but can't install in real device 应用程序可以在模拟器上正常运行,但不能在移动设备上运行 - App works fine on Emulator but not on Mobile device SQLite 在模拟器上完美显示检索到的数据,但在实际设备/应用程序中未检索到任何内容 - SQLite showing retrieved data perfectly on emulator, but doesn't retrieve anything on actual device/in app Flutter 应用程序在 android 工作室模拟器上完美运行,但 go 无法通过物理设备上的加载屏幕 - Flutter app runs perfectly on android studio emulator but doesn't go past the loading screen on physical device APK错误:Android应用程序可以在模拟器/设备上完美运行,但是当我从PlayStore下载时,应用程序总是在启动时崩溃 - APK error: Android app runs perfectly fine on emulator/device but when I download from the PlayStore the app always crashes on startup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM