https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Skolson5903

11/15/2020, 8:44 PM
I seem to be encountering an Android Studio issue in a project with MP modules that have android(), jvm(), and ios() targets, and am wondering if anyone else has seen this. Environment is kotlin 1.4.20-RC, gradle 6.7, Android Studio 4.1. Gradle builds of the MP modules in question work fine, so the gradle config is decent. I have an actual class implementation in the jvmMain sourceset that displays in android studio fine, with no errors. The exact same source in androidMain, which gradle also builds fine, shows in Android Studio with every import of a java package as an error. The "java" prefix in each package import is red as if the IDE doesn't see the jdk8 dependency only in the androidMain sourceset. But gradle sees it fine and builds the source with no errors, so the dependencies in the gradle config are corrrect. This doesn't happen in all my Kotlin MP projects, so there is something different about this one that I'm still trying to figure out. The same question with more detail (build.gradle.kts) is on Stack Overflow, at this link: Stack Overflow question . Thanks in advance for any info.
k

KamilH

11/16/2020, 6:08 AM
2 things to check: 1. Try switching order of
multiplatform
and
android-library
plugins and sync 2. Try comment-out
jvm
target and dependencies and sync
👍 1
s

Skolson5903

11/16/2020, 5:04 PM
Someone on SO found the answer:
Copy code
kotlin.mpp.enableGranularSourceSetsMetadata=true
That cured the issue. I haven't heard of that option until now, definitely need to read up 🙂 Thanks...
It's mentioned in this link: Migrating multiplatform project to 1.4.0
2 Views