As per latest https://developer.android.com/jetpack/androidx/releases/compose-kotlin
I can see that we can use
- Compose Compiler Version - 1.4.0
- Compatible Kotlin Version - 1.8.0
However, after upgrade to compose 1.4.0 and kotlin 1.8.0, I got the error below
I got this error
Failed to resolve: androidx.compose.ui:ui-tooling:1.4.0
Failed to resolve: androidx.compose.ui:ui-test-manifest:1.4.0
Failed to resolve: androidx.compose.ui:ui:1.4.0
Failed to resolve: androidx.compose.ui:ui-tooling-preview:1.4.0
Failed to resolve: androidx.compose.ui:ui-test-junit4:1.4.0
Did I miss anything?
CodePudding user response:
Yes, the libraries from the androidx.compose.ui
package for compose version 1.4.0
have not been released yet.
The latest version for each of these libs is 1.4.0-alpha04
. You can check the versions on this page
CodePudding user response:
Compose compiler and the other compose dependencies have different releases.
Currently only compose.compiler
has 1.4.0 stable.
To avoid this kind of problem you have different option:
Use the BOM
The Compose Bill of Materials (BOM) lets you manage all of your Compose library versions by specifying only the BOM’s version. The BOM itself has links to the stable versions of the different Compose libraries, in such a way that they work well together.
Going forward, Compose libraries will be versioned independently, which means version numbers will start to be incremented at their own pace.
Here you can find more info about BOM.
buildscript {
ext {
compose_compiler = '1.4.0' //compiler
}
//...
}
composeOptions {
kotlinCompilerExtensionVersion compose_compiler
}
dependencies {
// Import the Compose BOM
implementation platform('androidx.compose:compose-bom:2022.12.00')
//....
}
Or use different version in your build script:
buildscript {
ext {
compose_compiler = '1.4.0' //compiler
compose_version = '1.3.x' //compose dependencies
compose_material3 = '1.0.1' //material3 release
}
//...
}
and then:
composeOptions {
kotlinCompilerExtensionVersion compose_compiler
}
dependencies {
// compose releases (1.3.x)
implementation "androidx.compose.material:material:$compose_version"
//...
//material3
implementation "androidx.compose.material3:material3:$compose_material3"
}
CodePudding user response:
Apparently, the compose version and composeCompiler version are different.
For now, the compose version is at 1.4.0-alpha04
buildscript {
ext {
compose_ui_version = '1.4.0-alpha04'
}
}
While the composeCompiler is now 1.4.0
android {
...
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
}