Hi everyone, I encounteres an interesting issue: I...
# compiler
e
Hi everyone, I encounteres an interesting issue: I have a SDK that in Android .aar format, with Kotlin 1.7.10 to compile it. When use that aar in an Android+ java project, it works well. However when I use it in an Android + Kotlin 1.5.31 Project, it throws
Imcompatible classes we're found in dependencies. Remove them from classpath or use '-Xskip-metadata-version-check' to suppress errors.
The binary version of its metadata is 1.7.1, expected version is 1.5.1.
How does Android + Java work? And what is the best practice when writing an library in Kotlin? Should I make it compiled with 1.5 or even 1.4? I saw okhttp uses 1.7.10 as well to build the library(though it's not an aar) Thanks.
e
.aar or not doesn't make a difference. Java doesn't know or care about Kotlin metadata, but the Kotlin compiler does - it is necessary to enable Kotlin features such as top-level functions and typesaliases. Kotlin metadata evolves with each major release, and newer compiler always understands older metadata, but older compiler is only prepared to understand limited future metadata.