11

I have already installed cocoapods in my Mac.

Cocoapods

 $ pod --version
1.9.3

$ which pod
/Users/user/.rbenv/shims/pod

$  which gem
/Users/user/.rbenv/shims/gem

$  which ruby
/Users/user/.rbenv/shims/ruby

Problem

But if I add device specific codes like I setup firebase or add geolocator plugin, then clicking on Android studio Run green button, I always get below error:

Launching lib/main.dart on iPhone 11 Pro in debug mode...
Warning: CocoaPods not installed. Skipping pod install.
  CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
  Without CocoaPods, plugins will not work on iOS or macOS.
  For more info, see https://flutter.dev/platform-plugins
To install:
  sudo gem install cocoapods

CocoaPods not installed or not in valid state.
Error launching application on iPhone 11 Pro.

What didn't worked

  • I updated Mac OS Catalina (10.15.6)
  • I re-installed cocoapods couple of times, with different approaches (with homebrew, with system ruby, with rbenv ruby)
  • Updated to latest xcode

It didn't worked

What works

Finally, if I run below command in terminal it is working as expected:

flutter build ios --simulator
flutter run

So, I think its an issue with Android Studio. anyone else facing this issue, and have workaround for this problem?

Requirement

  • I want android studio to run project when I click on Android Studio Run icon.
2
  • I am also running into the same problem. I can run my app on terminal and it is fine, but the play button gives me cocoapods error. Have you fixed it? Commented Oct 1, 2020 at 18:45
  • What happens if you run the terminal that lives inside Android Studio? From there, you can check the ruby version and make sure it's the same. Sometimes the environments get out of sync Commented Mar 9, 2021 at 11:41

6 Answers 6

5

This is not a android studio issue, it is a pod version issue for flutter. Please downgrade your cocoapods and try again.

Here is my solution.

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup
sudo gem install cocoapods

Update: if you got still issue, please open it on xcode project and try run it. once you fixed issue on xcode, it will work on android studio, too

Update 2: please check your flutter sdk path. if there is any Capital letters, it can cause the issue.

Update 3: Try using Android Studio on termnial if all above methods do not work.

open /Applications/Android\ Studio.app 
Sign up to request clarification or add additional context in comments.

12 Comments

Hi Haley, I still think its an issue with android studio, because as I have already explained, CLI and Visual studio code is able to run the flutter. Not the android studio. Also I tried couple of different version of cocoapods already. and note that, I am using rbenv (version manager) to install different versions of ruby in my system, so that could be the root cause, but not entirely sure.
if so, did you try re-install android studio and android studio plugins for flutter and dart? on my case, the issue is just gone after I downgraded the pod version.
Yes I did. yeah, this is weird issue for me. Not sure if anyone else is facing this, but I am definitely facing it. Anyways now I am continuing with VS code.
what is your flutter sdk path?
Update 3: open /Applications/Android\ Studio.app solved the problem for me
|
1

Try launching Android Studio from Terminal:

open /Applications/Android\ Studio.app

It would then use another PATH variable than if started with launchpad. And that PATH would contain valid path to CocoaPods.

Taken from https://github.com/flutter/flutter-intellij/issues/4981#issuecomment-751443625

Comments

0

Yes, It's an Android Studio issue and this worked for me

flutter clean in flutter project dir

In Android Studio: File > Invalidate Caches / Restart > Invalidate and Restart

Now the project should run on Android Studio when you click on the run button.

Comments

0

this is happened to me on vscode because cocoapods is looking for ruby version 2.6 and what I did to fix it with rbenv

rbenv global 2.6.8
gem install cocoapods

then restart vscode

Comments

0

I had tried a large number of options, but Android Studio continued to fail. So I tried using the Terminal options. It is important to perform these while in the directory that holds your current project. Once you are in the right place, type :-

          flutter build ios --simulator

then type :- flutter run

That compiled and ran my code correctly. Oddly it subsequently fixed Android Studio so that my code ran in the simulator without needing further input via the terminal.

Blockage cleared.!

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

Step-1: Run command flutter clean Step-2: Check ios folder and if pod folder and podfile.lock is exist then delete it. Step-3 : Android studion in top bar in file=>invalidate cache=> restart. Step-4 : After open android studio again run command flutter pub get. Step-5 : Run project.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.