Closed mr3y-the-programmer closed 1 year ago
Hi @mr3y-the-programmer
I reproduced the issue in you project. I think it has something to do with the way how plugins get appliied.
I changed your setup a bit according to the official templates (disabled android though, but it should be possible to follow the approach):
Index: settings.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/settings.gradle.kts b/settings.gradle.kts
--- a/settings.gradle.kts (revision 0a11b543524e23e5d7a2ef04ac0b89785442cc46)
+++ b/settings.gradle.kts (date 1696001038618)
@@ -9,7 +9,19 @@
}
plugins {
id("de.fayard.refreshVersions") version "0.60.2"
- id("org.jetbrains.compose") version "1.5.2" apply false
+
+ val kotlinVersion = extra["kotlin.version"] as String
+ val agpVersion = extra["agp.version"] as String
+ val composeVersion = extra["compose.version"] as String
+
+ kotlin("jvm").version(kotlinVersion)
+ kotlin("multiplatform").version(kotlinVersion)
+ kotlin("android").version(kotlinVersion)
+
+ id("com.android.application").version(agpVersion)
+ id("com.android.library").version(agpVersion)
+
+ id("org.jetbrains.compose").version(composeVersion)
}
}
plugins {
@@ -25,6 +37,6 @@
}
}
rootProject.name = "Ludi"
-include(":androidApp")
+//include(":androidApp")
include(":shared")
-include(":desktopApp")
\ No newline at end of file
+include(":desktopApp")
Index: shared/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts
--- a/shared/build.gradle.kts (revision 0a11b543524e23e5d7a2ef04ac0b89785442cc46)
+++ b/shared/build.gradle.kts (date 1696000999093)
@@ -1,7 +1,6 @@
plugins {
- alias(libs.plugins.kotlin.multiplatform)
- alias(libs.plugins.android.library)
-// alias(libs.plugins.compose.multiplatform)
+ kotlin("multiplatform")
+ id("com.android.library")
id("org.jetbrains.compose")
}
@@ -72,4 +71,4 @@
}
namespace = "com.mr3y.ludi.shared"
-}
\ No newline at end of file
+}
Index: desktopApp/build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts
--- a/desktopApp/build.gradle.kts (revision 0a11b543524e23e5d7a2ef04ac0b89785442cc46)
+++ b/desktopApp/build.gradle.kts (date 1696001193239)
@@ -1,7 +1,5 @@
plugins {
- alias(libs.plugins.kotlin.jvm)
-// alias(libs.plugins.compose.multiplatform)
- application
+ kotlin("jvm")
id("org.jetbrains.compose")
}
@@ -19,7 +17,3 @@
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
-
-application {
- mainClass.set("MainKt")
-}
Index: gradle.properties
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>ISO-8859-1
===================================================================
diff --git a/gradle.properties b/gradle.properties
--- a/gradle.properties (revision 0a11b543524e23e5d7a2ef04ac0b89785442cc46)
+++ b/gradle.properties (date 1696001142779)
@@ -28,4 +28,7 @@
#KMP
kotlin.mpp.androidSourceSetLayoutVersion=2
-kotlin.mpp.stability.nowarn=true
\ No newline at end of file
+kotlin.mpp.stability.nowarn=true
+kotlin.version=1.9.10
+agp.version=8.0.2
+compose.version=1.5.2
Index: build.gradle.kts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/build.gradle.kts b/build.gradle.kts
--- a/build.gradle.kts (revision 0a11b543524e23e5d7a2ef04ac0b89785442cc46)
+++ b/build.gradle.kts (date 1696000942119)
@@ -1,11 +1,21 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+//plugins {
+// alias(libs.plugins.kotlin.multiplatform) version "1.9.10" apply false
+//// alias(libs.plugins.kotlin.jvm) apply false
+//// alias(libs.plugins.kotlin.android) apply false
+//// alias(libs.plugins.android.application) apply false
+//// alias(libs.plugins.android.library) apply false
+//// alias(libs.plugins.kotlinSerialization) apply false
+//// alias(libs.plugins.compose.multiplatform) apply false
+// id("org.jetbrains.compose") version "1.5.2" apply false
+//}
+
+
plugins {
-// alias(libs.plugins.kotlin.multiplatform) apply false
-// alias(libs.plugins.kotlin.jvm) apply false
-// alias(libs.plugins.kotlin.android) apply false
-// alias(libs.plugins.android.application) apply false
-// alias(libs.plugins.android.library) apply false
-// alias(libs.plugins.kotlinSerialization) apply false
-// alias(libs.plugins.compose.multiplatform) apply false
- id("org.jetbrains.compose") apply false
-}
\ No newline at end of file
+ // this is necessary to avoid the plugins to be loaded multiple times
+ // in each subproject's classloader
+ kotlin("multiplatform").apply(false)
+ id("com.android.application").apply(false)
+ id("com.android.library").apply(false)
+ id("org.jetbrains.compose").apply(false)
+}
And the error was gone.
It's better to follow this template: https://github.com/JetBrains/compose-multiplatform-template#readme
It's important to declare the plugins in the root build.gradle.kts:
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
kotlin("multiplatform").apply(false)
id("com.android.application").apply(false)
id("com.android.library").apply(false)
id("org.jetbrains.compose").apply(false)
}
Thanks @eymar. I tried following the steps and I can confirm it works, I've even enabled Android module using the same approach
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug Doing a gradle sync or even running a simple task like
gradlew clean
from IDE or command line fails with the message:Stacktrace:
Versions
To Reproduce Clone this branch https://github.com/mr3y-the-programmer/Ludi/tree/migrate_to_kmp, and do a gradle sync or run any gradle task, gradle configuration would fail.
Expected behavior The project's gradle configuration should complete successfully.
Additional context Sometimes, there is an additional line that appears randomly between attempts in the error message:
And idea.log file content: