Kotlin / kotlin-interactive-shell

Kotlin Language Interactive Shell
Apache License 2.0
587 stars 36 forks source link

Weird issue resolving dep in AS after using KI #124

Open fluxxion82 opened 1 year ago

fluxxion82 commented 1 year ago

Ok, so I'm this weird issue and not entirely sure what's going on, and hoping here can give me some insights.

I was doing some work in Android Studio, and wanted to test something out related to kotlinx datetime quickly, so I go to the command line and open KI. I try to add the repository, dependsOn, and import classes but couldn't get things to work right. This was the first time I had tried adding a maven repo and trying to access a library with KI. I never got it to work so I went to Intellij and did my test.

I go back to AS and it now can't resolve the kotlinx datetime library anymore (specifically for the version I was trying to use in KI). I cleared my gradle caches, uninstalled KI, reboot my computer but nothing has worked.

I added a resolutionStrategy in my build file to force the project to use an earlier version of kotlinx datetime and that gets the project working again, but I can't use the latest version, or at least the version i was using previously. My intellij project seems to be working ok with the latest datetime library.

The error in AS that I get is Unresolved reference errors. I'm using AS Flamingo Beta 4 (also have issues with Giraffe). On a mac m1.

example KI input:

[0] :repository https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-datetime/0.4.0
[1] :dependsOn org.jetbrains.kotlinx:kotlinx-datetime:0.4.0
WARNING File 'org.jetbrains.kotlinx:kotlinx-datetime:0.4.0' not found (Line_2.kts:1:1)
WARNING org.jetbrains.kotlin.org.eclipse.aether.resolution.DependencyResolutionException: Failed to read artifact descriptor for org.jetbrains.kotlinx:kotlinx-datetime:jar:0.4.0 (Line_2.kts:1:1)
[2] import kotlinx.datetime.Instant
ERROR Unresolved reference: datetime (Line_3.kts:1:16)
[3] :repository https://repo.maven.apache.org/maven2/
[4] :dependsOn org.jetbrains.kotlinx:kotlinx-datetime:0.4.0
[5] import kotlinx.datetime.Instant
ERROR Unresolved reference: Instant (Line_6.kts:1:25)
[6] import kotlinx.datetime.*
[7] :dependsOn org.jetbrains.kotlinx:kotlinx-datetime:0.4.0
[8] import kotlinx.datetime.*
[9] var insta = Instant.now().toString()
ERROR Unresolved reference: Instant (Line_10.kts:1:13)
[10] 

there were times I would add a repo and the dependsOn wouldn't complain, but then KI could only see this package and no classes in the package, kotlinx.datetime. I tried add the * to maybe see if that would catch the classes but no luck. I tried a bunch of different repositories but never actually got something to work.

I'm at a loss of what the issue could be or what else I can do. I'm wondering if there's anyway that KI could have affected what I'm seeing with AS, and if anyone has any ideas what could be causing the issue.

fluxxion82 commented 1 year ago

I finally figured out the correct repository url/dependsOn value to use (-jvm), but it hasn't helped AS from resolving the classes.

davidedelerma commented 10 months ago

Having the same issue. Any luck?

fluxxion82 commented 10 months ago

Having the same issue. Any luck?

No, it still happens if I use the particular version of the library. I don't hit the issue too often since there are newer versions of the library but it's definitely still a problem if I use code referencing the old lib version.