11

I am very new to KMM (Kotlin Multiplatform Mobile) and iOS development (including CocoaPods). I have come across the following build error in Android Studio.

Execution failed for task ':shared:podInstall'. java.io.IOException: Cannot run program "pod" (in directory "/Users/.../AndroidStudioProjects/.../iosApp"): error=2, No such file or directory

The directory definitely exists and I seem to be able to manually run pod commands from within the directory. I am not sure but it seems like this problem came about when I updated the Kotlin plugin from 1.5.0 to 1.5.10. This problem occurred even when starting a completely new KMM project.

I thought it might have something to do with Android Studio not being able to find the pod command so I added it to the path but that didn't seem to do anything. Any help with this would be appreciated.

user15134436
  • 131
  • 1
  • 4

2 Answers2

10

Check your Gradle JDK : Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle

Then select Gradle JDK -> Embedded JDK

Maybe you must execute in command line :

./gradlew :shared:podInstall
CmoiJulien
  • 659
  • 8
  • 6
  • 4
    Executing `./gradlew :shared:podInstall` helped me. I guess it's because it makes the task UP-TO-DATE so Gradle skips it when it runs next time (within Android Studio too). – deej Dec 17 '21 at 18:51
  • Running both 박현기 and CmoiJulien answers solved the problem for me. I couldn't finde the error cause tho. – Bernardo do Amaral Teodosio Jan 21 '22 at 20:07
  • 1
    As @deej said, this works because Android Studio skip the `pod install` thing the next time. However, when the task is executed again (e.g. when you change your gradle files), the error happens again. – noe Jan 27 '22 at 09:13
5

Have you tried File > Invalidate Cache and Restart? I had exactly same issue, but It got fixed after invalidate cache and restart.

박현기
  • 71
  • 3