Problem with updating compose version to 1.3.0-alpha01

Viewed 1098

I have an Android Studio project that works fine when I'm using Kotlin version 1.6.21 and compose version 1.2.0-rc01. The problem arises when I want to update both dependencies to the latest versions, which are 1.7.10 for Kotlin and 1.3.0-alpha01 for compose. The error that I get is:

Could not resolve all files for configuration ':app:kotlin-extension'. Could not find androidx.compose.compiler:compiler:1.3.0-alpha01. Searched in the following locations:

Required by: project :app

Any help?

Edit:

Now I'm using these versions:

kotlinCompilerExtensionVersion '1.7.10'

implementation "androidx.compose.ui:ui:1.3.0-alpha01"
implementation "androidx.compose.material:material:1.3.0-alpha01"
implementation "androidx.compose.compiler:compiler:1.2.0"
4 Answers

Compose compiler and the other compose dependencies have different releases.
Currently the latest version of compose.compiler is 1.3.1.

You easily use different versions in your build.gradle script:

buildscript {
    ext {
        compose_compiler = '1.3.1'.     //compiler
        compose_version = '1.2.0'.      //stable compose dependencies
        compose_alpha = '1.3.0-alpha01' //alpha releases
    }
    //...
}

And then:

composeOptions {
    kotlinCompilerExtensionVersion compose_compiler
}

dependencies {
   //stable releases
   implementation "androidx.compose.material:material:$compose_version"

   //alpha releases
   implementation "androidx.compose.ui:ui:$compose_alpha"
   implementation "androidx.compose.material3:material3:$compose_alpha"
}

An alternate Compose compiler version can be defined with composeOptions:

android {
    composeOptions {
        kotlinCompilerExtensionVersion "1.2.0"
    }
}

There's no need to add it as an implementation, which it definitely isn't.
runtimeOnly might eventually work, but it won't make it into the package.

There is a compatibility map for "Compose Compiler Version" compatible with "Compatible Kotlin Version" it can be found here:

so if you want to update to today's latest compose you specify:

...
composeOptions {
        kotlinCompilerExtensionVersion "1.3.0"
}
...

and then in the map you find the compatible kotlin version which is 1.7.10 and set that in the other gradle file:

plugins {
    id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
    ...
}

I am using compose_version is 1.3.0-beta01 which is working fine for me. You may use like below:

Step1: Project build.gadle is look like below:

   build script {

        ext {
            compose_version =  '1.3.0-beta01'
        }
     }

   plugins {
        id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
       
    }

Step2: module build.gadle looks like

  composeOptions {

    kotlinCompilerExtensionVersion compose_version
    kotlinCompilerVersion '1.5.21'

 }
Related