android - Is there anything to do in proguard while using kotlinx serialization? - Stack Overflow

I am using Kotlinx serialization in my KMP project.This is the plugins section of the build.gradle fil

I am using Kotlinx serialization in my KMP project.

This is the plugins section of the build.gradle file for shared module:

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
    alias(libs.plugins.ksp)
    alias(libs.plugins.room)
    alias(libs.plugins.skie)
    kotlin("plugin.serialization") version "2.0.20"
}

This is the gradle file for my androidApp:

plugins {
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.kotlinAndroid)
    alias(libs.pluginsposepiler)
    id("kotlin-parcelize")
    kotlin("plugin.serialization") version "2.0.20"
}

This is my project level gradle file:

plugins {
    //trick: for the same plugin versions in all sub-modules
    alias(libs.plugins.androidApplication).apply(false)
    alias(libs.plugins.androidLibrary).apply(false)
    alias(libs.plugins.kotlinAndroid).apply(false)
    alias(libs.plugins.kotlinMultiplatform).apply(false)
    alias(libs.pluginsposepiler).apply(false)
    kotlin("plugin.serialization") version "2.0.20"
}

When I run the app with minifyEnabled, I get this exception:

F4.h: Serializer for class 'a' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.

As per the offical docs (.serialization), it says that nothing has to be added in proguard.

However, only when I add

-keep @kotlinx.serialization.Serializable class * {*;}

am I able to run the project with minifyEnabled true.

Why does the behavior seem different from what the docs say?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745640987a4637689.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信