gpt4 book ai didi

android - Kotlin - 混淆的属性名称

转载 作者:行者123 更新时间:2023-11-30 00:38:35 25 4
gpt4 key购买 nike

我正在开发 Kotlin Android 应用程序,但在集成 Google Sign In 时遇到问题,当我获取 GoogleSignInAccount 以提取属性时,属性名称似乎被混淆了(或以其他方式混淆),这是一个属性在 AS 2.3 调试器上的显示方式的屏幕截图:

Debugger

下面是尝试访问这些属性的代码 fragment :

 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
}
})
}
}
}
}
}

谁能阐明为什么属性看起来像那样?当我尝试访问 idToken 或 id 时,它们始终为空,但是,无法访问“混淆”的属性名称,是这是一个 kotlin 错误还是我的错误?

任何帮助将不胜感激!

最佳答案

以下内容最初由@EugenPechanec 作为对问题正文的评论发布。应用了一些修改以提升阅读体验。


Fields 是 JVM 的一个术语,而不是 properties,后者是 Kotlin 术语。你在 JVM 上,你在调试器中看到的是支持 Kotlin 属性的混淆字段。 setter/getter 是公开的并保留原始名称。 Java .getDisplayName() 在 Kotlin 中是 .displayName

关于android - Kotlin - 混淆的属性名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42958916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com