Iunir Iakupov
02/07/2024, 5:50 PMimplementation(libs.androidx.lifecycle.viewmodel.compose)
How to fix it? Sorry for stupid question, but I've spent too much time on that already.CLOVIS
02/07/2024, 5:52 PMandroidx-lifecycle-viewmodel-compose = { … }
in the file gradle/libs.versions.toml
? It should be in the [libraries]
section.CLOVIS
02/07/2024, 5:54 PMIunir Iakupov
02/07/2024, 5:57 PMIunir Iakupov
02/07/2024, 5:58 PMExecuting tasks: [:composeApp:assembleDebug, :composeApp:assembleDebugUnitTest, :composeApp:assembleDebugAndroidTest] in project /Users/iuniriakupov/git/KotlinProject
Type-safe project accessors is an incubating feature.
> Configure project :composeApp
e: file:///Users/iuniriakupov/git/KotlinProject/composeApp/build.gradle.kts:38:42: Unresolved reference: lifecycle
w: Missing 'androidTarget()' Kotlin target in multiplatform project 'composeApp (:composeApp)'.
The Android Gradle plugin was applied without creating a corresponding 'android()' Kotlin Target:
plugins {
id("com.android.application")
kotlin("multiplatform")
}
kotlin {
androidTarget() // <-- please register this Android target
}
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/Users/iuniriakupov/git/KotlinProject/composeApp/build.gradle.kts' line: 38
* What went wrong:
Script compilation error:
Line 38: implementation(libs.androidx.lifecycle.viewmodel.compose)
^ Unresolved reference: lifecycle
1 error
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
==============================================================================
2: Task failed with an exception.
-----------
* Where:
Build file '/Users/iuniriakupov/git/KotlinProject/composeApp/build.gradle.kts' line: 38
* What went wrong:
Script compilation error:
Line 38: implementation(libs.androidx.lifecycle.viewmodel.compose)
^ Unresolved reference: lifecycle
1 error
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
==============================================================================
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to <https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
BUILD FAILED in 1s
Iunir Iakupov
02/07/2024, 5:58 PMCLOVIS
02/07/2024, 5:58 PMandroidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.7.0" }
but I have no idea which version the sample is written for. You can find the full list here: https://androidx.tech/artifacts/lifecycle/lifecycle-viewmodel-compose/CLOVIS
02/07/2024, 5:59 PM* What went wrong:
Script compilation error:
Line 38: implementation(libs.androidx.lifecycle.viewmodel.compose)
^ Unresolved reference: lifecycle
1 errorThis is the interesting part 🙂 But well, it's not teaching us much except that IntelliJ and Gradle agree on what's wrong, which probably means the only issue is the missing lifecycle dependency.
Iunir Iakupov
02/07/2024, 6:01 PMCLOVIS
02/07/2024, 6:01 PMIunir Iakupov
02/07/2024, 6:05 PMJoel Denke
02/07/2024, 8:11 PMIunir Iakupov
02/07/2024, 8:41 PMJoel Denke
02/07/2024, 8:45 PMIunir Iakupov
02/07/2024, 8:50 PM[versions]
agp = "8.2.2"
android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"
androidx-activityCompose = "1.8.2"
androidx-appcompat = "1.6.1"
androidx-constraintlayout = "2.1.4"
androidx-core-ktx = "1.12.0"
androidx-espresso-core = "3.5.1"
androidx-material = "1.11.0"
androidx-test-junit = "1.1.5"
compose = "1.5.4"
compose-compiler = "1.5.8"
compose-plugin = "1.6.0-alpha01"
junit = "4.13.2"
kotlin = "1.9.21"
ktor = "2.3.7"
logback = "1.4.14"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" }
androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-espresso-core" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.7.0" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
ktor-server-tests = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
Iunir Iakupov
02/07/2024, 8:52 PMJoel Denke
02/07/2024, 8:56 PMIunir Iakupov
02/07/2024, 9:20 PMApp.kt
file in composeApp/src/androidMain/kotlin
But in fact it's not there. It's in the composeApp/src/commonMain/kotlin
Iunir Iakupov
02/07/2024, 10:09 PMCLOVIS
02/08/2024, 8:39 AMApp.kt
fix it? If not, can you show us the contents of App.kt
?Joel Denke
02/08/2024, 8:42 AMJoel Denke
02/08/2024, 8:43 AMJoel Denke
02/08/2024, 8:47 AMJoel Denke
02/08/2024, 8:50 AMIunir Iakupov
02/08/2024, 9:31 AMApp.kt
fixed it. Thank you all for helping me!Joel Denke
02/08/2024, 9:34 AMRichie Rodríguez
02/15/2024, 6:08 PMRichie Rodríguez
02/15/2024, 6:09 PMRichie Rodríguez
02/15/2024, 6:12 PMproject_path/gradle/libs.versions.toml
, I got the project compiling/running after downgrading agp version from "8.2.0" to "8.1.4"Richie Rodríguez
02/15/2024, 6:13 PM