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

Sean Proctor

08/18/2022, 1:22 PM
I think I'm stuck between two bugs trying to get Android Studio to behave nicely. Since updating to Kotlin 1.7.0, some libraries (moko-resources-compose) don't resolve in the IDE. https://issuetracker.google.com/issues/231701341 adding the workaround suggested there (adding commonMain to the androidMain srcDir) fixes that issue, but then androidMain doesn't seem to be able to resolve anything from commonMain, strangely. I've tried using almost every version of AGP and AS. currently I'm on dolphin with AGP 7.3.0-rc01. Has anyone else had this issue and figured out a working solution?
m

Matthias Geisler

08/18/2022, 1:25 PM
Is it a pure Android project or KMP/KMM?
s

Sean Proctor

08/18/2022, 1:26 PM
KMP targetting android and jvm, using jetbrains compose
m

Matthias Geisler

08/18/2022, 1:32 PM
You could try to use the Android Dependency directly AS might complain about the double dependency but it helped in my case
s

Sean Proctor

08/18/2022, 1:37 PM
I just tried that. Nothing changed.
m

Matthias Geisler

08/18/2022, 1:47 PM
Pity
s

Sean Proctor

08/18/2022, 1:48 PM
Yeah, thanks for the suggestion.
m

Matthias Geisler

08/18/2022, 1:49 PM
I noticed that in some cases (libs only) enabling more variants (like iOS, js) to match those of the dependencies also solved that...but this is not always applicable (sry I cannot help you more)
e

eygraber

08/18/2022, 2:21 PM
Have you tried Electric Eel? That's the only version I've been able to get it to work with.
s

Sean Proctor

08/18/2022, 2:22 PM
I have. I'll try it again.
With AGP 7.4 alpha?
e

eygraber

08/18/2022, 2:24 PM
You also need to remove
kotlin.mpp.hierarchicalStructureSupport=false
if you have it set in your gradle properties
With AGP 7.4 alpha
Yes, I'm using latest AS and AGP alpha
s

Sean Proctor

08/18/2022, 2:30 PM
I appears to be the same as with dolphin. without the commonMain srcDir to androidMain, stringResource is an unresolved reference, and with adding the srcDir, nothing in androidMain can resolve things from commonMain
This is just in the IDE, everything builds fine either way.
e

eygraber

08/18/2022, 2:31 PM
Are you using the configuration cache?
s

Sean Proctor

08/18/2022, 2:32 PM
Not as far as I'm aware.
e

eygraber

08/18/2022, 2:35 PM
Hmm that's odd, it's been working for me for a while now on EE
Do you see the same issue with the repro project in https://issuetracker.google.com/issues/231701341
s

Sean Proctor

08/18/2022, 2:54 PM
I'm not sure. I see plenty of errors in the IDE. It looks like it's unable to resolve any external dependency.
e

eygraber

08/18/2022, 5:12 PM
🤔 I wouldn't expect any errors (at least that's the state in my machine).
s

Sean Proctor

08/22/2022, 12:50 AM
I think Thursday I was not having a very smart day. Revisiting this, I realized I downloaded the version from that bug report. after changing the agp version to 7.4.0-alpha09, I get this error: e: /home/sproctor/Desktop/231701341/build-logic/src/main/kotlin/com/eygraber/galgal/gradle/kmp.kt: (3, 36): Unresolved reference: _ab93fe423733af93ad8bc6bc1a01bf3e
e

eygraber

08/22/2022, 1:35 AM
Oh that's something with the generated accessors where the package could change depending on a few factors. You can get it to work by replacing
_ab93...
with the correct package
s

Sean Proctor

08/22/2022, 11:09 AM
Looks like it's either not being generated here or I'm completely blind this morning. The second option is a definitely possibility. Maybe 7.4.0-alpha02 was a hard dependency here. Anyway, thanks for trying.
e

eygraber

08/23/2022, 9:29 AM
If it's still not working you can try deleting your gradle cache. That worked for me a couple of times after having made all the other changes.
s

Sean Proctor

08/27/2022, 12:53 PM
I think the original issue is fixed in 7.4.0-alpha10!
6 Views