小编moh*_*jid的帖子

原因:com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException:协议消息包含无效标签(零)

启动活动时,我的应用程序在 getEncryptedSharedPrefs 处崩溃:

    if(getEncryptedSharedPrefs().getString("pinSettingsLogin", "")!!.isEmpty()){
        getEncryptedSharedPrefs().edit()
            .putString("pinSettingsLogin" , "0000")
            .apply()
    }
Run Code Online (Sandbox Code Playgroud)

出现此错误:

Caused by: com.google.crypto.tink.shaded.protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero).
Run Code Online (Sandbox Code Playgroud)

奇怪的是,这个 if 语句适用于 Android 10 和 11,但不适用于 Android 12。这个 if 语句之所以在这里,是因为在下面的“if”中,我检查 pinSettingsLogin = 0000 是否如此,以便它自行进入新活动。

    if(getEncryptedSharedPrefs().getString("pinSettingsLogin", "").equals("0000")){
        val i = Intent(this, SettingsActivity::class.java)
        startActivity(i)
        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left)
    }
Run Code Online (Sandbox Code Playgroud)

android kotlin android-studio

21
推荐指数
2
解决办法
9964
查看次数

标签 统计

android ×1

android-studio ×1

kotlin ×1