Kotlin / kmp-basic-sample

Example of Kotlin multiplatform project
Apache License 2.0
1.01k stars 185 forks source link

Dependency of commonMain not visible in commonMain source set, but in androidMain #40

Closed aradomski closed 3 years ago

aradomski commented 4 years ago

Versions:

How to reproduce: When adding dependencies to commonMain in newly generated project. Dependencies are visible for the androidMain source set but not for commonMain. See attached screenshot Zrzut ekranu 2020-09-11 o 14 21 24

StefMa commented 4 years ago

Because retrofit is not a multiplatform library and can't be used in common (and other targets except JVM and android).

On Fri, Sep 11, 2020, 2:22 PM Adam Radomski notifications@github.com wrote:

Versions:

  • Kotlin Multiplatform Mobile Plugin version: 0.1.1-release-51-Studio4.1
  • Kotlin plugin version: 1.4.10-release-Studio4.1-1
  • Android Studio version: 4.1. RC 2
  • OS: macOS Mojave 10.14.6
  • Gradle: 6.5
  • Kotlin gradle plugin: 1.4.0
  • Build gradle: 4.0.1

How to reproduce: When adding dependencies to commonMain in newly generated project. Dependencies are visible for the androidMain source set but not for commonMain. See attached screenshot [image: Zrzut ekranu 2020-09-11 o 14 21 24] https://user-images.githubusercontent.com/136780/92924994-1a9d0500-f43a-11ea-9830-5933bc0a4415.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Kotlin/kmm-sample/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOBQ657F5BUTSHLY32XBUTSFIJB7ANCNFSM4RHLSDUQ .

AHFZ commented 3 years ago

I have the same issue! I added Ktor core to the commonMain dependency but I can use it androidMain instead of commonMain! Did you find any solution?

cl3m commented 3 years ago

I've fixed the problem in Android Studio by using the correct kotlin gradle plugin version :

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21")

Then File -> Invalidate Caches / Restart

AHFZ commented 3 years ago

I've fixed the problem in Android Studio by using the correct kotlin gradle plugin version :

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21")

Then File -> Invalidate Caches / Restart

Thanks, It works now!

kosiara commented 1 year ago

For me it was the upgrade of Android-Studio to the newest: Android Studio Dolphin | 2021.3.1 Patch 1