Julian Cuevas
Julian Cuevas

Reputation: 35

Kotlin - Obfuscated Property Names

I'm developing a Kotlin Android app and I'm having an issue integrating Google Sign In, when I get the GoogleSignInAccount in order to extract properties, the property names seem to be obfuscated (or otherwise jumbled up), here's a screenshot of the way the properties look on AS 2.3 debugger:

Debugger

Here's the snippet of code that tries to access those properties:

 private fun googleSignInResult(data : GoogleSignInResult) {
    if (data.isSuccess) {
        if (data.signInAccount != null) {
            val account = data.signInAccount
            val authData = HashMap<String, String>()

            authData["id_token"] = account?.idToken.let { it } ?: return
            authData["id"] = account?.id.let { it } ?: return

            val task = ParseUser.logInWithInBackground("google", authData)

            task.continueWith { user ->
                if (task.isCancelled) {
                    Log.d(TAG, "User cancelled Google login")
                } else if (task.isFaulted) {
                    Log.d(TAG, "Failed: " + task.error)
                } else {
                    this.user = task.result
                    this.user?.put("email", account?.email)
                    this.user?.put("name", account?.displayName)
                    this.user?.put("firstName", account?.displayName)

                    this.user?.saveInBackground({ error ->
                        if(error != null) {
                            Log.d(TAG, "Error: " + error.message)
                            this.user?.deleteInBackground()
                            ParseUser.logOutInBackground()
                        } else {
                            //Logged in successfully
                        }
                    })
                }
            }
        }
    }
}

Can anyone shed some light on why is it that properties look like that?, when I try to access idToken or id they're always null, however, the property names that are "obfuscated" can't be accessed, is this a kotlin bug or is it my error?

Any help will be much appreciated!

Upvotes: 1

Views: 527

Answers (1)

glee8e
glee8e

Reputation: 6419

The following content is originally posted by @EugenPechanec as a comment to the question body. Some modification is applied to promote reading experience.


Fields, a term from JVM, is not properties, which is a Kotlin term. You're on JVM, and what you see in the debugger are obfuscated fields backing the Kotlin properties. The getters are public and retain original names. Java .getDisplayName() is .displayName in Kotlin.

Upvotes: 2

Related Questions