Seeing a lint error with beta09 for modules that d...
# compose
t
Seeing a lint error with beta09 for modules that don’t directly have Compose enabled … 🧵 ⬇️
Copy code
/Users/...: Error: Unexpected failure during lint analysis of GifsList.kt (this is a bug in lint or one of the libraries it depends on)
  
Message: 'void kotlinx.metadata.jvm.KotlinClassHeader.<init>(java.lang.Integer, int[], java.lang.String[], java.lang.String[], java.lang.String, java.lang.String, java.lang.Integer)'

The crash seems to involve the detector androidx.compose.runtime.lint.ComposableCoroutineCreationDetector.
You can try disabling it with something like this:
    android {
        lintOptions {
            disable "CoroutineCreationDuringComposition"
        }
    }
  
Stack: NoSuchMethodError:KotlinMetadataUtilsKt.toHeader(KotlinMetadataUtils.kt:102)←KotlinMetadataUtilsKt.getKmDeclarationContainer(KotlinMetadataUtils.kt:56)←KotlinMetadataUtilsKt.toKmFunction(KotlinMetadataUtils.kt:39)←ComposableUtilsKt.isComposable(ComposableUtils.kt:128)←ComposableUtilsKt.isComposable(ComposableUtils.kt:150)←ComposableBodyVisitor.isComposable(ComposableUtils.kt:176)←ComposableUtilsKt.isInvokedWithinComposable(ComposableUtils.kt:71)←ComposableCoroutineCreationDetector.visitMethodCall(ComposableCoroutineCreationDetector.kt:47)
  
  You can set environment variable LINT_PRINT_STACKTRACE=true to dump a full stacktrace to stdout. [LintError]
Kotlin: 1.5.10 Compose on other modules: beta09 AGP: 4.2.1 Wondering if I need to update/add some dependency, or if this is a legit issue…
l
Looks like a legit issue / edge case we didn’t account for. Could you share the code it is failing on?
👌 1
Oh actually hm, I didn’t see the NoSuchMethodError - that’s pretty weird. Is it failing on every non-Compose module? Does it fail on Compose modules?
t
The files its failing on are fairly regular: an AAC
ViewModel
that uses
viewModelScope
, a
Fragment
that uses
lifecycleScope
, and two other regular classes that take in a
coroutineScope
and use that to launch coroutines. Not failing for modules that have Compose dependencies. Not failing for all other modules as well…just a select few.
The modules where it’s failing are declared as dependencies on the modules with Compose added.
Going to disable
CoroutineCreationDuringComposition
checks in those failing modules for the moment. Will create an issue & try to have an isolated repro if possible.
143 Views