Solvedkotlinx.serialization kotlin Multiplatform module: build errors

I tried using kotlinx.serialization in a kotlin multiplatform project in a commons module with some small model classes looking like the following:

@Serializable
open class Document {
    var _id: String? = null
    var _rev: String? = null
}

@Serializable
class User : Document() {

    var username: String = ""
    var email: String = ""
    var rollen: List<UserRoles> = emptyList()

    companion object {
        val TYPE = "User"
    }
}

But when building via command-line I get following errors:

Unresolved reference: kotlinx
Cannot access 'Serializable': it is internal in 'kotlin.io'
This class does not have a constructor

Its mentioned in the description that it should work with the kotlinx-serialization-runtime-common dependency which I am using. The plugin should stay the same as far as I read.

I am using kotlin 1.2.21, but already tried 1.2.20, 1.2.10 with the same results.
Gradle 4.4.1

18 Answers

✔️Accepted Answer

I received the same error message ("Cannot access 'Serializable': it is internal in 'kotlin.io'"), but only because I forgot the import kotlinx.serialization.*. IntelliJ did not suggest to add this import automatically, so I first assumed some configuration issue. Maybe it helps someone arrivin here via Google.

Other Answers:

I get rid of that error by import java.io.Serializable. I hope it helps.

You need to apply plugin: 'kotlinx-serialization' in platform buildscript too

@fisiodes Try to add import kotlinx.serialization.* to your file

Related Issues:

34
kotlinx.serialization kotlin Multiplatform module: build errors
I received the same error message (Cannot access 'Serializable': it is internal in 'kotlin.io') but ...
12
kotlinx.serialization Strict JSON encountered unknown key
Latest versions of both Kotlin Serialization and JakeWharton's Converter should do: ...
6
kotlinx.serialization how to parse JSONArray to List<CustomObject> ?
If actually want to parse a root-level array you have to create serializer for List<CustomObject> an...
12
json Using fifo_map
As I said before in my previous comment there is a way to do it without a change in the libraries ...
4
json json({}) gives null instead of empty object with GCC and -std=c++17
I had a similar problem related to dumping At least there the value json::value_t::null set in defau...
246
sheetjs How to simply export a Worksheet to xlsx?
There are two issues: each object is mapped to a row so if you want a row with name John and city Se...
167
prettier Change HTML/JSX formatting to have one attribute/prop per line
The point I am trying to make is that the vertical space matters Wasting it (too much) has negative ...
105
prettier [resolved] [HTML] allow corresponding option to jsxBracketSameLine
I don't think I've ever seen any markup language with the closing brackets on a separate line I'd li...
96
fastapi WARNING: Unsupported upgrade request.
This error is not part of the FastAPI codebase When attempting to run this (using UviCorn) it starts...
90
prettier Feature Request: breakBeforeElse
This feels like one of those I can't adopt prettier unless options that was mentioned in the 1.0 rel...
87
prettier Add option to omit semicolons in output
I use standard.js which is a popular no-configuration style guide & linter They insist on a semicolo...
83
editor.js JSON to back to html, How?
+1 to have something like readOnly or viewMode or even better to have toHtml() method which will all...
79
sheetjs Doesn't work with browserify or webpack.
I was able to get it building by adding the following to my webpack config: EDIT: please raise a new...
72
prettier Space after function name in declarations
This is one of the reasons I've had to step away from adopting Prettier I would be quite happy with ...
69
prettier Ugly line break in a template string
Maybe templates should never be wrapped because it looks ugly most of time This input looks better t...
64
fastapi [QUESTION] How to bridge Pydantic models with SQLAlchemy?
I just finished integrating Pydantic ORM mode into FastAPI it is released as version 0.30.0 🎉 The n...
63
prettier Space after function keyword in anonymous functions
+1 for space after function keyword Crockford supports this: If a function literal is anonymous ...
59
ponzu no go files in /home/user/go/src/github.com/ponzu-cms/ponzu
try running go get -u github.com/ponzu-cms/ponzu/.. via copy / paste that exact command. ...
59
prettier Break on multiple chained calls
Could we manage chains like we manage object literals in that if they have a break within them they ...
56
prettier Respect paren + newline
I've made a PR that: Adds wrapping parens back to JSX Arrow functions (when the JSX is multiline): U...
52
fastapi [QUESTION] How to send 204 response?
Instead of returning None and instead of injecting the response just return a newly created response...
50
prettier Prettier 2.0 – 2.0 2020
@lydell you fogot Change the default for singleQuote to true We already have a Prettier 2.0 issue – ...
45
sheetjs Corrupt XLSX file after downloading
Ok Sorry for the monologue but I solved it: In the frontend when making the GET Request ...
44
sheetjs Change header´s title when using json_to_sheet
There's no json_to_xlsx function you probably mean json_to_sheet That being said the easiest way is ...
42
fastapi OpenAPI UI not working properly when using automatic swagger-ui CDN (swagger-ui-3.30.1)
Thanks for reporting it and for all the discussion here everyone! 🚀 ☕ Indeed it's a bug in Swagger ...
39
prettier Option to add parenthesis to multiline expressions
Just because an arrow function is multiline doesn't necessarily make it complex and call for using {...
34
react jsonschema form Should we move to Bootstrap v4?
IMO we should get rid of Bootstrap to be fully agnostic Maybe we can still support frameworks by cre...
34
fastapi [QUESTION] Is this the correct way to save an uploaded file ?
@classywhetten FastAPI has almost no custom logic related to UploadFile -- most of it is coming from...
34
fastapi [QUESTION] Storing object instances in the app context
@ebarlas you're 100% right Description In Flask ...
30
fastapi [QUESTION] aiohttp integration best practice
That is one way if you want create a new session for every request You can also use a singleton appr...
29
json schema spec v6 annotation: named enumerations
My first reaction was that's a cumbersome mess and then I wrote it out and now I agree with you :-) ...
27
sheetjs how to set the automatic width?
@cjlhll Please see my solution get maximum width from the json data set column width ...
26
json_serializable.dart type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast
See flutter/flutter#17417 – please add a 👍 there to encourage the flutter folks to run on it ...
26
fastapi logs with FastAPI and Uvicorn
Doing : is exactly what I was looking for ! Thank you dbanty. Hello Thanks for FastAPI easy to use i...
26
lowdb node@14.16.0 Error [ERR_REQUIRE_ESM]
I opened a PR opened here to address this issue You can test it by installing the package from PR's ...
22
prettier Allow inline method chaining if line length does not exceed printWidth
There are many popular patterns chaining method calls using enzyme Just to give you some context on ...
22
fastapi [QUESTION] Client Credentials Flow openAPI UI
I think I found the solution for others looking to implement the code - tiangolo has already enabled...
21
prettier Typescript cannot parse // inside of JSX
@Kuzmenkoar Until the bug is fixed I think this is the nicest workaround: I'm having a problem with ...
21
fastapi FastAPI 0.65.2 POST request fails with "value is not a valid dict" when using the Requests library; 0.65.1 works (with a caveat)
Can confirm this still happens! We solved it by adding a -H Content-Type: application/json to the cu...
20
sheetjs merge cells from Array of Arrays
You need to build up the worksheet first then add the merges to the worksheet Hi ...
20
normalizr An empty array of results should produce an empty entity
If you don't receive any entities of a certain type Problem If the data for an entity is an empty ar...
19
prettier RxJS pipe chaining get formatted on a single line
I agree with @yannickglt As a developer it's much easier to reason about an RxJS pipeline if every s...
19
fastapi [QUESTION] Using pydantic models for GET request query params? Currently not possible, have to use dataclasses or normal classes.
@LasseGravesen You would do it like this: Check the docs here: https://fastapi.tiangolo.com/tutorial...
18
Newtonsoft.Json Serialization of decimals does not respect precision
I agree that this is unexpected behaviour at the very least and imho it is also a bug For 15 the pre...
18
jsonschema Package version mechanism incompatible with AWS Lambda
@Julian Perhaps a blurb can be added to the docs related to deploying this library using Serverless?...
18
json5 Should we consolidate the human-readable JSON efforts?
The obvious choice for a file extension of course is 🤪 I'd like to write comments in my .json files...
18
react jsonschema form Validate onBlur?
Why was this closed? This should be kept open and a prop should be added to the <Form> so that this ...
18
fastapi [QUESTION] about threads issue with fastapi.
Hello Hi I have a question about the threads issue with fastapi ...
17
browser compat data Breaking changes: scoping the npm package and dropping Node.js 8 support (RFC for BCD 2.0)
I have now merged #7155 completing the process of renaming the package to @mdn/browser-compat-data a...
17
prettier [1.6] Tracking issue
I just fixed all the issues I could find running it through the fb codebase and understood what was ...