2021年3月26日星期五

Kotlin Multiplatform Mobile work with Jetpack Compose?

There are 2 problems that do not allow to generate compatibility between these technologies

Jetpack Compose

The first problem is that it only works with Android Studio Canary x.

  • Android Studio 4.2 Beta 6

Jetpack Compose is a preview feature, and support for Compose is included only in Canary versions of Android Studio. To use Compose in your app project, download and install the latest Canary version of the IDE.

Jetpack Compose works with:

  • Android Studio Canary
  • Kotlin 1.4.30
  • distributionUrl: 6.8.2
  • AGP: 7.0.0-alpha11
  • JavaVersion.VERSION_11

Kotlin Multiplatform Mobile

And the second problem is that Android Studio Canary builds have a bug in Kotlin Multiplatform Mobile. I am using the following:

  • Android Studio Arctic Fox | 2020.3.1 Canary 11
Android Studio Arctic Fox | 2020.3.1 Canary 11  Build #AI-203.7148.57.2031.7209405, built on March 15, 2021  Runtime version: 11.0.8+0-b944-P17168821 amd64  VM: OpenJDK 64-Bit Server VM by N/A  Current Desktop: ubuntu:GNOME  
  • In gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip  
  • In build.gradle (Project)
buildscript {      dependencies {          classpath 'com.android.tools.build:gradle:7.0.0-alpha11'      }  }  
  • JavaVersion.VERSION_11

Error (issue/KT-43944):

A problem occurred configuring project ':kmm_shared'.  > Configuration with name 'testApi' not found.  * Exception is:  Caused by: org.gradle.api.artifacts.UnknownConfigurationException: Configuration with name 'testApi' not found.  

The only workaround at the moment for KMM to work is use Android Studio Beta (but this is not compatible with Jetpack Compose).

Install Android Studio – version 4.2 or higher.

Given this there would be 2 solutions that I could not face. Have Compose work on the Android Studio Beta build or fix the KMM bug in Android Studio Canary.

It should be noted that KMM and Jetpack Compose use different versions of AGP and gradle distributions. Then it occurs to me, I don't know if it is possible, that deferred versions coexist in the same project.

Any suggestion is welcome.

Thanks

https://stackoverflow.com/questions/66811117/kotlin-multiplatform-mobile-work-with-jetpack-compose March 26, 2021 at 12:38PM

没有评论:

发表评论