简体   繁体   中英

How to use different Kotlin versions for modules in Android Studio (WearOS module)

I have an Android project with several modules, the phone app module and some library modules. They all work with CoposeCompiler 1.2.0 and Kotlin version 1.7.0. Now, I'd like to add a WearOS module to create an app for smartwatches using JetpackCompose as well. The problem is that the latest stable version of ComposeCompiler for WearOS (1.1.1) does need Kotlin 1.6.10 to work, and won't build without that version.

I've tried to add Kotlin 1.6.10 as a dependency along with the existing one (1.7.0), but it thows an error when I try to build the project (duplicate classes). I did it in project-level Gradle file and module-level Gradle file.

I also tried to use the suppressKotlinVersionCompatibilityCheck=true tag inside kotlinOptions for WearOS module, but it also thows an error:

java.lang.NoSuchMethodError: 'boolean org.jetbrains.kotlin.ir.declarations.IrClass.isInline()'

I don't know how could I achive that. The only option that I seem fasible is to create another project specifically for the WearOS app, but I'd like to have all the modules together in a single project. Any help will be welcomed!

Acccording to thedoc : "Using version 1.0 of Compose for Wear OS requires using version 1.2 of androidx.compose libraries and Kotlin 1.7.0." This is slightly out of date but basically WearOS 1.1.1 does not need Kotlin 1.6.10.

Try this:

        kotlin_version = '1.8.0'
        wear_compose_version = '1.1.1'
        compose_version = '1.3.3'
        compose_compiler_version = '1.4.0'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM