I have an android library(aar) that was developed with Kotlin(version: 1.7.10) I want to use my library inside another project with Kotlin version 1.4.32 or any Kotlin version except 1.7.10, but I get this error during build:
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.2.
Full Error:
/Users/user/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.7.10/bac80c520d0a9e3f3673bc2658c6ed02ef45a76a/kotlin-stdlib-common-1.7.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.4.2.
So my question is, what should I do to be able to use my library inside projects with any different Kotlin version? Or How can I build a Kotlin library that works for every Kotlin version.
Should I have any Gradle configuration to do that?
Additional info
Device: Mac book m1 pro, and Asus with intel chipset.
OS: OSX, and Windows
IDE: Android Studio Chipmunk 2021.2.1 patch 2
AGP: 7.3.3
Cleaning the project or Invalidate cache and restarting the project does not help.
Also changing the version of Kotlin used in the library from 1.7.10 to 1.6.21 doesn't help. It will produce the same error with 1.7.10 or other versions.
--release 11
.