I have a code base which is tightly coupled with BoradcastChannel and I can't update that for now. But I want to upgrade the dependencies to their latest, use kotlin2 and compose.
I have changed my setup to use Kotlin 2.2.20 and compose 2.2.20-2.0.2 and Firebase BOM 34.2.0.
When I force the dependencies to import strictly Coroutine-BOM 1.8.1 my build fails with following error:
java.lang.NullPointerException: Cannot invoke "java.util.List.get(int)" because "path" is null
And if I run
./gradlew :app:dependencies --configuration stagingMyAppDebugRuntimeClasspath | grep coroutines
Here is part of the tree:
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:{strictly 1.8.1} -> 1.8.1
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1 (c)
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1 FAILED
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.8.1 (c)
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.8.1 -> 1.10.2 (c)
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.8.1 (c)
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.1 -> 1.9.0 (c)
| | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.1 -> 1.10.2 (c)
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:{strictly 1.8.1} FAILED
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-rx2:{strictly 1.8.1} -> 1.8.1
| | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1 FAILED
Is it possible to do what I want? If so what I am doing wrong here? Or what are the version compatibilities?
Here is the project build.gradle
plugins {
id 'org.jetbrains.kotlin.multiplatform'
id('kotlinx-serialization')
id('kotlinx-atomicfu')
id('com.github.node-gradle.node')
}
if (gradle.ext.isOsx) {
apply plugin: 'org.jetbrains.kotlin.native.cocoapods'
}
apply from: "$rootDir/utils.gradle"
if (gradle.ext.isOsx) {
...
}
node {
version = '16.0.0'
yarnVersion = '1.6.0'
distBaseUrl = 'https://nodejs.org/dist'
download = true
}
if (gradle.ext.shouldBuildJava) {
ext.createDirectoryLink(
projectDir.toPath().resolve("src/jvmCommonMainPure").toFile(),
projectDir.toPath().resolve("src/jvmCommonMain").toFile(),
)
if (gradle.ext.shouldBuildAndroid) {
apply plugin: 'com.android.library'
ext.createDirectoryLink(
projectDir.toPath().resolve("src/jvmCommonMainAndroid").toFile(),
projectDir.toPath().resolve("src/jvmCommonMain").toFile(),
)
}
}
sourceCompatibility = 17
targetCompatibility = 17
archivesBaseName = 'common'
version = library_version
if (gradle.ext.shouldBuildAndroid) {
android {
namespace 'my.app.common.lib'
buildFeatures {
viewBinding true
buildConfig true
}
compileOptions {
sourceCompatibility jvm_target
targetCompatibility jvm_target
}
defaultConfig {
compileSdk android_compile_sdk_version as int
minSdk android_min_sdk_version as int
targetSdk android_target_sdk_version as int
versionCode version_code as int
versionName library_version
testInstrumentationRunner "my.app.ComponentRegistryProvidingTestRunner"
}
packagingOptions {
exclude 'META-INF/kotlinx-coroutines-core.kotlin_module'
exclude 'META-INF/kotlinx-serialization-runtime.kotlin_module'
exclude 'META-INF/atomicfu.kotlin_module'
exclude 'META-INF/ktor-http.kotlin_module'
exclude 'META-INF/ktor-utils.kotlin_module'
exclude 'META-INF/ktor-io.kotlin_module'
exclude 'META-INF/kotlinx-coroutines-io.kotlin_module'
exclude 'META-INF/kotlinx-io.kotlin_module'
exclude 'META-INF/ktor-http-cio.kotlin_module'
exclude 'META-INF/ktor-client-core.kotlin_module'
}
buildTypes {
release {
...
}
debug {
debuggable true
}
}
flavorDimensions "environment", "product"
productFlavors {
flavour1 {
...
}
flavour2 {
...
}
def envShortNames = [:]
def deepLinkEnvShortNames = [:]
staging {
...
}
development {
...
}
production {
...
}
}
sourceSets {
..
}
}
}
kotlin {
if (gradle.ext.isOsx) {
cocoapods {
...
}
}
sourceSets.configureEach {
languageSettings {
apiVersion = kotlin_language_version
languageVersion = kotlin_language_version
}
}
targets {
if (gradle.ext.shouldBuildJava) {
if (gradle.ext.includePureJvm) {
jvm('jvmPure')
}
if (gradle.ext.shouldBuildAndroid) {
androidTarget()
}
}
if (gradle.ext.isOsx) {
...
}
}
sourceSets {
commonMain {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$kotlin_coroutines_version")) {
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core"){
version { strictly("$kotlin_coroutines_version") }
}
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialization_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialization_version"
implementation "org.jetbrains.kotlinx:atomicfu:$kotlin_atomicfu_version"
implementation("io.ktor:ktor-client-core:$ktor_version") {
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib"
}
api("com.soywiz.korlibs.klock:klock:$klock_version") {
attributes {
attribute(
Usage.USAGE_ATTRIBUTE,
project.objects.named(Usage, 'kotlin-api')
)
}
}
}
}
commonTest {
...
}
if (gradle.ext.shouldBuildJava) {
if (gradle.ext.includePureJvm) {
jvmPureMain {
dependsOn commonMain
kotlin.srcDir('src/jvmCommonMainPure/kotlin')
dependencies {
implementation "com.github.megatronking.stringfog:interface:$stringfog_version"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$kotlin_coroutines_version")){
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core"){
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-rx2"){
version { strictly("$kotlin_coroutines_version") }
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:atomicfu:$kotlin_atomicfu_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialization_version"
implementation "org.reactivestreams:reactive-streams:$reactive_streams_version"
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
implementation("com.squareup.retrofit2:adapter-rxjava2:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:$retrofit_kotlinx_serialization_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "org.threeten:threetenbp:$threetenbp_version"
implementation("com.soywiz.korlibs.klock:klock-jvm:$klock_version") {
transitive = false
attributes {
attribute(
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.attribute,
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.jvm
)
attribute(
org.gradle.api.internal.project.ProjectInternal.STATUS_ATTRIBUTE,
'release'
)
}
}
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "com.ibm.icu:icu4j:$icu4j_version"
}
}
jvmPureTest {
kotlin.srcDir('src/jvmCommonTest/kotlin')
kotlin.srcDir('src/jvmCommonTest/java')
dependencies {
implementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}
}
}
if (gradle.ext.shouldBuildAndroid) {
androidTest {
...
}
androidInstrumentedTest {
...
}
androidUnitTest {
...
}
androidMain {
dependsOn commonMain
kotlin.srcDir('src/mobileMain/kotlin')
kotlin.srcDir('src/jvmCommonMainAndroid/kotlin')
kotlin.srcDir('src/androidMain/kotlin')
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$kotlin_coroutines_version")){
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core"){
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-rx2"){
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android"){
version { strictly("$kotlin_coroutines_version") }
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:atomicfu:$kotlin_atomicfu_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialization_version"
implementation "org.reactivestreams:reactive-streams:$reactive_streams_version"
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxkotlin_version"
implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.squareup.retrofit2:adapter-rxjava2:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:$retrofit_kotlinx_serialization_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "androidx.core:core:$androidx_core_version"
implementation "androidx.appcompat:appcompat:1.7.1"
implementation "androidx.browser:browser:$androidx_browser_version"
implementation "org.threeten:threetenbp:$threetenbp_version"
....
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
...
}
}
}
}
if (gradle.ext.isOsx) {
iOSMain {
...
}
iOSX64Main {
dependsOn iOSMain
}
iOSArm64Main {
dependsOn iOSMain
}
}
}
targets.configureEach {
compilations.configureEach {
compileTaskProvider.get().compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
freeCompilerArgs.add("-XXLanguage:+InlineClasses")
}
if (name.containsIgnoreCase("test")) {
def mainCompilation = compilations.findByName("main")
if (mainCompilation != null) {
associateWith(mainCompilation)
}
}
}
}
}
if (gradle.ext.shouldBuildAndroid) {
dependencies {
testImplementation "junit:junit:$junit_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "androidx.test:rules:$androidx_test_version"
testImplementation "androidx.test.ext:junit:$androidx_test_ext_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$androidx_lifecycle_version"
implementation("com.soywiz.korlibs.klock:klock-android:$klock_version") {
transitive = false
attributes {
attribute(
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.attribute,
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.androidJvm
)
}
}
api "com.github.megatronking.stringfog:interface:$stringfog_version"
implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$androidx_lifecycle_version"
api(platform("com.google.firebase:firebase-bom:$firebase_bom_version")){
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-bom"
}
api "com.google.firebase:firebase-analytics"
api "com.google.firebase:firebase-auth"
api "com.google.firebase:firebase-messaging"
api "io.ktor:ktor-client-core:$ktor_version"
api "io.ktor:ktor-client-core-jvm:$ktor_version"
}
}
configurations {
compileClasspath
}
if (gradle.ext.isOsx) {
tasks.podspec.doLast {
outputs.files.forEach {
it.text = it.text.replace("gradlew\"", "gradlez\" --jdk17 --no-daemon --console=plain --wrapper-dir=../ -DPLATFORM_NAME=\$PLATFORM_NAME")
}
}
afterEvaluate {
configurations.configureEach {
def disambiguateConfiguration = Attribute.of('my.app.disambiguateConfiguration', String)
if (name.startsWith('pod')) {
attributes {
attribute(disambiguateConfiguration, 'pod')
}
} else if (name.endsWith('Fat')) {
attributes {
attribute(disambiguateConfiguration, 'fat')
}
}
}
}
}
Here is my app build.gradle:
plugins {
id( 'com.android.application')
id('kotlin-android')
id("org.jetbrains.kotlin.plugin.compose") version "2.2.20"
id("com.google.devtools.ksp")
id('kotlinx-serialization')
}
apply from: "$rootDir/utils.gradle"
android {
namespace 'my.app'
compileOptions {
...
}
buildFeatures {
viewBinding true
buildConfig true
compose true
}
packagingOptions {
exclude 'META-INF/kotlinx-coroutines-core.kotlin_module'
exclude 'META-INF/kotlinx-serialization-runtime.kotlin_module'
exclude 'META-INF/atomicfu.kotlin_module'
exclude 'META-INF/ktor-http.kotlin_module'
exclude 'META-INF/ktor-utils.kotlin_module'
exclude 'META-INF/ktor-io.kotlin_module'
exclude 'META-INF/kotlinx-coroutines-io.kotlin_module'
exclude 'META-INF/kotlinx-io.kotlin_moduleg'
exclude 'META-INF/ktor-http-cio.kotlin_moindule'
exclude 'META-INF/ktor-client-core.kotlin_module'
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
defaultConfig {
...
}
buildTypes {
....
}
flavorDimensions "environment", "product"
def somethingProducts = []
productFlavors {
...
}
productFlavors
.matching { it.dimension == "product" }
.collect {
[sourceSets.getByName(it.name),
somethingProducts.contains(it.name)]
}
.each {
def (srcSet, hasSomething) = it
def path = hasSomething ? "something" : "nothing"
srcSet.java.srcDirs += [file("src/$path/java")]
srcSet.res.srcDirs += [file("src/$path/res")]
srcSet.assets.srcDirs += [file("src/$path/assets")]
}
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("development") && variant.buildType.name == "release") {
setIgnore(true)
}
}
clean {
delete "$rootDir/${project.name}/"
}
copyOutputs(applicationVariants)
}
composeCompiler {
...
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
implementation "com.github.megatronking.stringfog:interface:$stringfog_version"
implementation "com.github.megatronking.stringfog:xor:$stringfog_version"
implementation project(':app-common')
implementation project(':common')
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxkotlin_version"
implementation 'androidx.navigation:navigation-compose:2.9.4'
implementation 'androidx.compose.ui:ui-tooling-preview-android:1.9.1' implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation("com.squareup.retrofit2:adapter-rxjava2:$retrofit_version") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$kotlin_coroutines_version")){
version { strictly("$kotlin_coroutines_version") }
}
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android"){
version { strictly("$kotlin_coroutines_version") }
}
implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$androidx_lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$androidx_lifecycle_version"
implementation "androidx.constraintlayout:constraintlayout:$androidx_constraint_layout_version"
implementation "androidx.percentlayout:percentlayout:$androidx_percent_layout_version"
implementation "androidx.preference:preference-ktx:$androidx_preference_version"
implementation("com.google.android.material:material:$material_version") {
exclude group: 'androidx.core', module: 'core'
exclude group: 'androidx.appcompat', module: 'appcompat'
}
implementation "androidx.core:core-ktx:$androidx_core_version"
implementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
implementation "androidx.transition:transition:$androidx_transition_version"
implementation "androidx.biometric:biometric:$androidx_biometric_version"
testImplementation "junit:junit:$junit_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
androidTestImplementation "androidx.test:rules:$androidx_test_version"
androidTestImplementation "androidx.test.ext:junit:$androidx_test_ext_version"
implementation "com.github.AndreasMattsson:FragNav:$frag_nav_version"
implementation "io.github.pilgr:paperdb:$paper_db_version"
implementation "com.google.android.gms:play-services-auth:$play_services_auth_version"
implementation(platform("com.google.firebase:firebase-bom:$firebase_bom_version")) {
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-bom"
}
implementation "com.google.firebase:firebase-auth"
implementation "com.google.firebase:firebase-perf"
implementation "com.google.firebase:firebase-storage"
implementation "com.google.firebase:firebase-messaging"
implementation "com.google.firebase:firebase-analytics"
implementation "com.google.firebase:firebase-crashlytics"
implementation 'com.github.tapadoo:alerter:7.2.4'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.jkwiecien:EasyImage:2.0.3'
implementation 'com.github.permissions-dispatcher:permissionsdispatcher:4.9.2'
ksp 'com.github.permissions-dispatcher:permissionsdispatcher-processor:4.9.2'
implementation 'com.github.bumptech.glide:glide:5.0.4'
implementation 'jp.wasabeef:glide-transformations:4.3.0'
ksp 'com.github.bumptech.glide:compiler:5.0.4'
implementation 'jp.wasabeef:blurry:4.0.1'
implementation files('libs/cardstack-0.3.1-beta0.aar')
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation "com.airbnb.android:lottie:$lottie_version"
implementation("com.airbnb.android:lottie-compose:$lottie_version")
implementation "com.google.android.gms:play-services-tagmanager:18.3.0"
implementation "com.google.android.gms:play-services-basement:18.8.0"
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0@aar'
implementation "androidx.viewpager2:viewpager2:$androidx_pager2_version"
implementation "org.threeten:threetenbp:$threetenbp_version"
implementation "androidx.exifinterface:exifinterface:$androidx_exifinterface_version"
implementation platform("androidx.compose:compose-bom:2025.09.00"){
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-bom"
}
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-graphics-android"
implementation "androidx.compose.material3:material3"
implementation "androidx.constraintlayout:constraintlayout-compose:1.1.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$androidx_architecture_version"
implementation "io.coil-kt:coil-compose:2.7.0"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'androidx.compose.ui:ui-viewbinding:1.9.1'
implementation 'androidx.fragment:fragment-compose:1.8.9'
}
tasks.withType(JavaCompile) {
options.fork = true
}