-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serializer for class is not found even marked the class as @Serializable #1105
Comments
Try this: |
This seems to be a proguard configuration problem. The suggested solution should fix it as it certainly makes a static reference to the serializer. However decodeFromString should be inline reified and do this too. |
Yes. I believe it is an issue from R8. |
Stumbled upon this one as well. Downgraded the version to 1.0.0-RC (was RC2) and the issue disappeared. |
It seems to be an Android issue. Could you please provide a reproducing project with your R8 configuration? |
🤦♂️ It is fixed by adding the following the instruction about proguard from readme.md
|
I had same issue that yours! Serializables data clases seemed dissapear only during build release and I got the same error. |
Note, you will get this error if you have not added serializations to your gradle plugins section: plugins { |
I assume this can be closed now |
For anyone having issues using this in android studio, check gradle website Also make sure you have, on the same file, in dependencies { } the line: And remove comments (specially if they have links) near the build statements. That can interfere according to my tests. Make sure you have the imports in the .kt files: IDK if this is also part of the problem, but also make sure you have this in your proguard-rules.pro file (which is part of the gradle scripts) Finally, try using other grade JDK's by going to gradle settings. It's probably best to use Android's. And consider doing invalidate caches and restart. I've been trying on this issue for 5 hours. Yes. |
I ran into this issue recently after I had refactored my android apps' package in a kotlin multiplatform project. I needed to add rules to keep the serializers from both the androidApp package and the core library. My proguard looks something like:
|
For those where the solutions above were not working. -keepattributes Annotation, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt
-dontnote kotlinx.serialization.SerializationKt
# Keep Serializers
-keep,includedescriptorclasses class com.company.package.**$$serializer { *; }
-keepclassmembers class com.company.package.** {
*** Companion;
}
-keepclasseswithmembers class com.company.package.** {
kotlinx.serialization.KSerializer serializer(...);
}
# When kotlinx.serialization.json.JsonObjectSerializer occurs
-keepclassmembers class kotlinx.serialization.json.** {
*** Companion;
}
-keepclasseswithmembers class kotlinx.serialization.json.** {
kotlinx.serialization.KSerializer serializer(...);
} |
Describe the bug
To Reproduce
Attach a code snippet or test data if possible.
Having a data class JwtResult
and trying to parse the Json to JwtResult.class by
val returnedPayload = Json { ignoreUnknownKeys = true }.decodeFromString<JwtResult>(decodedPayload)
Exception was thrown in release build (minifyEnabled), but not debug build.
Seem the class was gone during the build process.
Expected behavior
successfully parsing the JSON
Environment
The text was updated successfully, but these errors were encountered: