jesusdmedinac
Published in

jesusdmedinac

KMM project shows “‘pod install’ command failed with code 1”. on Android Studio running on M1 chip

KMM project shows “‘pod install’ command failed with code 1”. on Android Studio running on M1 chip

If you have a new mac with any serie of chip M1, you may be facing this error while creating a new KMM (Kotlin Multiplatform Mobile) project on Android Studio.

As far as I investigate, this is not a M1 problem. But let review it together.

Just a little context. I’m using a MacBook Pro 14" 2021 with Apple M1 Pro chip.

And for Android Studio, I’ve installed the Android Studio Bumblebee | 2021.1.1 Patch 2.

And finally, I’ve installed Kotlin version 211–1.6.10-release-923-AS7442.40 and Kotlin Multiplatform Mobile plugin version 0.3.1(211–1.6.10-release-960-IJ)-89.

Creating a new KMM project

Ok, I’m assuming that you’re trying to create a new KMM project using Android Studio.

The configuration is not important for this article, but I’m using next:

But let pay attention at next step:

If you create your project using iOS framework distribution as a Regular Framework, you may not have any problem since CocoaPods is not used to compile the project.

Kotlin Multiplatform module is integrated via internal Gradle task and Xcode Build Steps configuration. It does not require 3rd party tools.

But, what about using CocoaPods? we just need to select it and click finish, right? Well, is not so simple.

KMM project shows “‘pod install’ command failed with code 1”. on Android Studio running on M1 chip

What’s happening? why pod install does not works?

A quick research give me the answer

https://youtrack.jetbrains.com/issue/KT-50195#focus=Comments-27-5656239.0-0

Basically, cocoapods 1.11.0 and later introduced a problem with the encoding. CocoaPods seems to know require UTF-8 encoding. Could we confirme this? Not sure how. I just found this issue on Github:
https://github.com/CocoaPods/CocoaPods/issues/10939

How we could solve this?

Assuming that next command returns empty:

echo $LANG

Then, export environment variable. Since I’m using zsh, my file is named .zshrc. I opened it using command:

open -e ~/.zshrc

And add in the file next line:

export LANG=en_US.UTF-8

After saving your .zshrc file, you must run next command:

source ~/.zshrc

Finally, if your Android Studio is still open, just close it and open it again.

Final considerations

Even if this is not a specific M1 problem, I only faced this issue with my new MacBook Pro M1 Pro. If this is helpful for you, let me now in the comments.

Also, I was facing more issues related with IOS simulator, but it is a subject for another article.

--

--

--

I’m a kotlin developer expert. I love to create multi platforms apps always promoting best practices.

Recommended from Medium

Why Players Play MyLottoCoin?

Lessons learnt (the hard way) using Firebase RealTime Database

Flutter Architecture

High order function in Android data binding.

Native Android screenshot/image sharing in Unity using FileProvider

Edit and Convert the Audios by integration of Huawei Audio Editor Kit in Android apps (Kotlin)

OnCollisionEnter vs OnTriggerEnter - Which do I use?

Intermediate: Edit, Extract and Convert Audio using Huawei Audio Editor Kit in Android

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jesús Daniel Medina Cruz

Jesús Daniel Medina Cruz

I'm a Senior Android Engineer expert in mobile apps.

More from Medium

Android Dagger with a MultiModule structure

Jetpack Compose ScrollableTabRow Indicator Matches Width of Text

Let’s do ChromeCast Videos with Android. — Part 4

Android Stack Weekly — Issue #5