Hi, all. Is there an easy to follow guide for how ...
# multiplatform
d
Hi, all. Is there an easy to follow guide for how to upgrade a project's dependencies; i.e., AGP, Kotlin, etc? I want to migrate my project's viewmodel from the current implementation (which uses ides from Kodeco's book on KMP) to using KMP-ObservableViewModel. But that requires upgrading several parts of our project, which are what was provided by the original KMP project created by Kotlin Multiplatform Wizard.
I was able to upgrade the AGP plugin pretty easily:
Copy code
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 07ae32b..4c2562e 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,5 +1,5 @@
 [versions]
-android-gradle-plugin = "8.5.0"
+android-gradle-plugin = "8.9.1"
 sonarqube-plugin = "4.4.1.3373"
 kotlin = "1.9.24"
 activity-compose = "1.8.0"
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b7f6793..3ca022e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
 #Sat Feb 17 16:54:35 EST 2024
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
Now I'm trying to upgrade the Compose compiler following these directions: https://developer.android.com/develop/ui/compose/compiler and am having no luck. Adding the version reference and the plugin to the libs.version.toml file and the root gradle file worked. But when I added the plugin reference to my shared module and android app it gives me 21 errors and fails.
So I've taken the approach to incrementally try to migrate the project to newer versions of dependencies. Upgrading AGP worked easily, as mentioned above. I removed activity-compose as an unused dependency (seems it was added by KMW when the project was created). And I was able to upgrade kotlin from 1.9.24 to 2.0.21 with minimal effort: just had to upgrade some Gradle options to use the newer compiler options DSL. Where I'm stuck now is trying to upgrade Kotlin to 2.1.0. As soon as I do that and let Android Studio do its thing, it fails with: ``````
What should I change at this point to ultimate move to Kotlin 2.1.20 so I can use the latest KMP-ObservableViewModel?
j
Are you keeping them in sync? KMP ObservableVM has its releases tied to the Kotlin version. Latest one supports 2.1.20: https://github.com/rickclephas/KMP-ObservableViewModel/releases/tag/v1.0.0-BETA-10 Same with KSP, in case you have it.
d
@Jacob Ras I'm trying to add that version of KVM-OVM as a new dependency to use it. The problem is that when I update my project to use a newer version of Kotlin, I'm getting the errors I documented above, and I'm not finding a clear cause for the error. (edit) Sorry, maybe I misunderstood you. Are you suggesting I bump both KMP-OVM and Kotlin versions at the same time? I'll give that a try now and respond with the result. (2nd edit) Tried that. It reduced the number of errors by one to 11 when I bumped Kotlin to 2.1.0 and KMP-OVM to -beta-8.
The errors all seem to be related to the ios and apple targets, looking at the output.
Stuff like:
Copy code
e: org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.IdeCommonizedNativePlatformDependencyResolver failed on :shared::shared/appleMain
java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.library.impl.BuiltInsPlatform org.jetbrains.kotlin.library.KotlinLibraryKt.getBuiltInsPlatform(org.jetbrains.kotlin.library.BaseKotlinLibrary)'
	at org.jetbrains.kotlin.gradle.plugin.ide.FactoriesKt.KlibExtra(factories.kt:82)