0

I'm using Firebase Authentication email&pass for Sign in. With database setting "Start in test mode" and change the rules for both read&write to "true". It really works perfectly via USB debugging. But when I generate for release signed APK, it shows error in build output with Message like this,

C:\Users\Public\MyAppName\app\firebase-database (Access is denied)

and also i've tried this firebase-authentication-not-working-in-signed-apk

and stil not worked for me.

any solution?

My code :

class LoginActivity : AppCompatActivity() {

lateinit var auth: FirebaseAuth


override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_login)
    supportActionBar!!.hide()
    window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)


    auth = FirebaseAuth.getInstance()

    val curretuser = auth.currentUser
    if (curretuser != null) {
        startActivity(Intent(this@LoginActivity, ProfileActivity::class.java))
        finish()
    }

    login()
}


private fun login() {
    bt_loginbuttonLogin.setOnClickListener {

        if ( TextUtils.isEmpty(et_usernameinputLogin.text.toString())){
            et_usernameinputLogin.setError("Masukan User Name")
            return@setOnClickListener
        }
        else if ( TextUtils.isEmpty(et_passwordinputLogin.text.toString())){
            et_passwordinputLogin.setError("Masukan password")
            return@setOnClickListener
        }
        auth.signInWithEmailAndPassword(et_usernameinputLogin.text.toString(), et_passwordinputLogin.text.toString())
            .addOnCompleteListener {
                if (it.isSuccessful) {
                    Toast.makeText(this@LoginActivity, "login berhasil", Toast.LENGTH_LONG).show()
                    startActivity(Intent(this@LoginActivity, ProfileActivity::class.java))
                    finish()
                } else {
                    Toast.makeText(this@LoginActivity, "Email Atau Pasword Salah", Toast.LENGTH_LONG).show()
                }
            }
    }

    tv_registertextLogin.setOnClickListener{
        startActivity(Intent(this@LoginActivity, RegistrationActivity::class.java))
    }
}
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
tankian vei
  • 27
  • 1
  • 5

1 Answers1

0

solved with this video, thanks internet.

this link

i was wrong to add SHA certificate fingerprints into my firebase console. now i can generate release signed APK.

tankian vei
  • 27
  • 1
  • 5