Ali Khaleqi Yekta
06/18/2022, 11:59 AMB
depends on module A
. Module A
has some code inside its commonMain
that module B
can access, because it depends on A
. The thing is, the code inside module A
can be accessed by any sourceSet
of module B
, EXCEPT from androidMain
!!! I can even access the code written in A
from `B`'s jvmMain
, but not androidMain
. When I try to do so, Android Studio (The latest stable version), says:
Unresolved reference: {NameOfTheClass}
---
Add dependency on module '{NameOfMyProject}.A.commonMain'
I don't exactly know when the problem has occurred, but I guess it was after updating the version of some dependencies (especially kotlin 1.6.10 to 1.6.21). I tried changing the versions again and cleaning the project every time; I tried invalidating the caches, I even migrated from a Linux based system to Windows; nothing worked. Some of the current versions:
Android build tools: 33.0.0
app compat: 1.4.2
Kotlin: 1.6.21
coroutines: 1.6.2
Kotlinx Datetime: 0.3.2
Kotlinx Serialization: 1.3.3
core ktx: 1.8.0
activity compose: 1.5.0-rc01
coil: 2.1.0
koin: 3.2.0
jvm targets: 11
compose: 1.1.1
Android gradle: 7.2.1
Kotest: 5.3.0
moko resources: 0.20.1
ktor: 2.0.2
...
UPDATE:
When I downgraded android gradle to 7.1.3, the app successfully compiles and I can run it inside the emulator. However, the IDE still shows the Unresolved dependency error, even though it compiles! How to fix this?
UPDATE:
Downgrading the android gradle plugin to 7.1.3
and adding: kotlin.mpp.hieraricalStructureSupport=false
solved the issue, BUT, made the jb compose not work in `commonMain`s.ephemient
06/18/2022, 12:35 PMAli Khaleqi Yekta
06/18/2022, 12:38 PMAli Khaleqi Yekta
06/18/2022, 12:47 PMkotlin.mpp.hieraricalStructureSupport=false
Solved the issue that rised from the IDE!ephemient
06/18/2022, 3:14 PMephemient
06/21/2022, 5:35 PM