Android studio flutter project giving pod not installed error

Viewed 4100

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.
5 Answers

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 

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.

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

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.!

Related