I am having a problem building a KMM project in An...
# multiplatform
o
I am having a problem building a KMM project in Android Studio with the following message " Cannot locate tasks that match 'sharedtestClasses' as task 'testClasses' not found in project ':shared'."
7
s
Hey did anyone find a solution for this problem? It just happened to me after updating Android Studio to
Android Studio Iguana | 2023.2.1
and several KMP projects won't build anymore 🙈
plus one 3
Ok, I even get the problem when creating a all new KMP project from scratch in Android Studio with the KMP plugin.
s
Same here, we're facing the same issue in our KMM project.
a
I tested by creating new project with and without shared tests both worked fine and even my old projects are also running fine. So unfortunately unable to reproduce the issue on my side.
e
I started to get this issue when upgrading the AGP version to 8.3, downgrading to 8.2.2 again solved the problem
s
Thanks @Enol Simón. But unfortunately that doesn't do the trick for us.
e
I solved this too by downgrading to AS Hedgehog and AGP 8.2.2. I ran into another issue when running
./gradlew clean build
from CLI (something about
> Invocation of 'Task.project' by task ':shared:linkDebugFrameworkIosArm64' at execution time is unsupported.
), but that was solved after I upgraded Kotlin from
1.9.20
to
1.9.23
.
s
Including
testClasses()
inside
kotlin { }
block of shared modules build.gradle solves the issue for me.
m
I've been researching this
testClasses
issue for a while and I can see it has something to do with AS Iguana. The workaround does work, though I fear it may affect other things down the line. For example, I used
resValue
in my gradle file to access different strings in the manifest based on the variant. That stopped working for the
processDebugAndroidTestResources
task. It could be unrelated though. Here are some google issues tracking this: https://issuetracker.google.com/issues/315023802 https://issuetracker.google.com/issues/328871352
t
In my case my "grade.properties" file contained the line: org.gradle.configuration-cache=true. Setting that value to false fixed the problem for me. Cleaning the project wouldn't work for me. I never tried clearing the cache. (I don't think that the gradle cache and grade configuration cache are exactly the same thing because I do have org.gradle.caching=true). So based on my observations, I suspect that this issue is a Kotlin gradle plugin bug with the configuration cache. I did get a warning that AGP 8.3 was a version greater than Kotlin was tested with, but I had the same problem whether I used AGP "8.2.x" or AGP "8.3.x". Hossein Amina posted a solution of adding the line "task("test classes) to your build script. That solution also worked for me but it might cause problems using your tests. I would suspect that if you deleted your "shared" tests that too might avoid this issue; but that's not what you really want to do. And lastly, I am using AS Iguana, so I don't suspect that's where the problem originates from as I don't think that the gradle configuration cache is tied to the version of android studio that your running.
e
adding task(“testClasses”) increases build time significantly for me, anyone else?
m
It should no longer be needed in the latest version of Android Studio. Koala
s
It does, but I don't think it is needed anymore as this issue is fixed with the new Android Studio Koala.
e
thanks! works without it in Koala for me to
1164 Views