Menu

1 / 5

Moving an Android App to Kotlin Multiplatform With AGP 9: Seven Traps

DEV Community: ios·Nesim Razon·about 14 hours ago
#wR8Wqi5u
#devtoios#devto#dev#android#module
Reading 0:00
15s threshold

I moved a small Compose game to Kotlin Multiplatform so it could also run on iPhone. The Kotlin part was easy, the build setup was not. These are the seven traps I hit with Android Gradle Plugin 9 and Compose Multiplatform, in the order I hit them, and the checks that told me nothing else had changed.

1. The application plugin and the multiplatform plugin no longer share a module

With Android Gradle Plugin 9 the Kotlin Multiplatform plugin cannot be applied to a module that also uses the Android application plugin. The shared code needs its own library module that uses the new Android library plugin for multiplatform. The app module stays a normal Android application and depends on it. The Kotlin migration guide also asks for a recent Gradle, 9.1 or newer.

2. Unit tests that quietly stop running

I moved the game rules and their ten unit tests into the shared module, ran the build and got a green result. Then I looked at the log: the Android test task of the shared module said there was nothing to run.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.