找不到引用的类kotlin.KotlinPackage

时间:2018-09-09 17:11:55

标签: android kotlin base64 proguard

我尝试将“ -dontwarn kotlin.KotlinPackage”添加到proguard-rules.pro,但无法正常工作。 我在代码中使用Base64,但找不到错误所在。当我禁用缩小功能时,没有问题。

警告

Warning: Base64Kt: can't find referenced class kotlin.KotlinPackage

我的代码

val decoded_note = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        Base64.getDecoder().decode(LocalData.with(this@MainActivity.applicationContext).read(getString(R.string.hashed_note)).toByteArray(Charsets.UTF_8))
    } else {
        android.util.Base64.decode(LocalData.with(this@MainActivity.applicationContext).read(getString(R.string.hashed_note)).toByteArray(Charsets.UTF_8), android.util.Base64.DEFAULT)
    }
    val old_note = String(decoded_note, charset("UTF-8"))
    note_EditText.setText(old_note)

    note_save_button.setOnClickListener{
        val new_note=note_EditText.text.toString()

        val hashed_note= if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            Base64.getEncoder().encodeToString(new_note.toByteArray(charset("UTF-8")))
        } else {
            android.util.Base64.encodeToString(new_note.toByteArray(charset("UTF-8")), android.util.Base64.DEFAULT)
        }

        LocalData.with(this@MainActivity.applicationContext).write(getString(R.string.hashed_note),hashed_note.toString())
    }
}

1 个答案:

答案 0 :(得分:0)

我已经解决了清理项目的问题。 构建->清理构建

相关问题