Hello, I am having some problems with Gradle + An...
# multiplatform
m
Hello, I am having some problems with Gradle + Android Studio on Mac OSX. It looks like Android Studio does not mark most of the source folders of one of my submodules as source roots which breaks code-completion. You can see in the first screenshot that only
androidMain/kotlin
is marked as source folder. The strange thing is that this only occurs on Mac OSX. On Ubuntu everything works fine (second screenshot). The versions of Android Studio, Kotlin, Plugins etc are the same on both machines. The command line build also works on both machines. Does anyone here know how to fix this? I would also like to know why some source folders are marked with a blue square and others with three vertical bars. Does this have any deeper meaning?
Oh and I did the clean, build, invalidate caches dance. Didn't work 😉
s
Hmm, dunno if this is useful, but in Intellij Ultimate on Mac all my sourcesets for a KMP 1.6.10 single-module project show correctly and operate correctly. Opening the exact same project on the same Mac OS in Android Studio Chipmunk also looks fine in the "Project" tab, using either the "Project" or "Android" views in the "Project" tab. Sourceset names are in bold when the folders match the gradle name, and the kotlin sub-folders show blue. So I'm unsure what's up here - your snaps above almost look like the sourceset is pointing one folder level too low, even on Ubuntu where it evidently still manages to work. In mine, "commonMain" for example is bold and the "kotlin" subdir is a blue folder with no bracketed source name next to it, because "commonMain" is both the sourceset main directory and the gradle sourceset name (they match). I'd have to see your sourceset defs determine what's causing that. If it helps to see a setup that works, check out https://github.com/skolson/KmpIO for both structure and the matching build.gradle.kts with the sourcesets defined.
One other probably useless tidbit I never noticed before. If I open the same project on Windows with Intellij Ultimate, the source directories display just like your Ubuntu snap until the gradle sync is complete. Once the initial sync is complete, the project then shows all the source directories correctly. I have no idea if this is useful to your issue or not, but FWIW...
m
The problem was that one of my Gradle tasks crashed during synchronisation. The task in question called
binaries.getFramework
, which since Kotlin 1.5.32 throws an exception if
binaries.framework.baseName
is not set in
build.gradle
. Since the task is also iOS-specific, the problem only occurs on Mac. I only noticed this when I opened the project in Intellij Idea, where the error was immediately displayed. Android Studio didn't give me any indication that Gradle sync had failed.... So your answer was definitely relevant to the problem I had, thanks 👍