Android studio flutter project giving pod not installed error

2,693

Solution 1

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 

Solution 2

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

Share:
2,693
przbadu
Author by

przbadu

BY DAY: full-stack freelancer BY NIGHT: I write codes, do stupid stuff with it, sometimes I win and sometimes bug!!, as a programmer, Its always competition between me and bug..... Yeah Yeah!! I write test cases for my features o_0. “ Computers are good at following instructions, but not at reading your mind. ” - Donald Knuth

Updated on December 22, 2022

Comments

  • przbadu
    przbadu over 1 year

    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.
  • przbadu
    przbadu over 3 years
    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.
  • Haley Huynh
    Haley Huynh over 3 years
    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.
  • przbadu
    przbadu over 3 years
    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.
  • Haley Huynh
    Haley Huynh over 3 years
    what is your flutter sdk path?
  • przbadu
    przbadu over 3 years
    /home/me/flutter
  • Haley Huynh
    Haley Huynh over 3 years
    flutter doctor --verbose
  • martomstom
    martomstom about 2 years
    Update 3: open /Applications/Android\ Studio.app solved the problem for me
  • Zenko
    Zenko about 2 years
    Tried almost all the solutions I found for the last 2 hours. None worked. flutter run and Xcode all works. But Android Studio does not work. Invalidate cache, restart, clean project, etc. Uninstall and reinstall, Nothing works. Did anyone get a clue?
  • Haley Huynh
    Haley Huynh about 2 years
    did you try on vs code?
  • Zenko
    Zenko about 2 years
    open /Applications/Android\ Studio.app works but this is a workaround. Is there a permanent solution? P.S: I want to use AS rather than VS code.
  • Tarun Chawla
    Tarun Chawla about 2 years
    I am also facing this issue, definitely an android studio issue. Does not happen on terminal and visual studio code.
  • Haley Huynh
    Haley Huynh about 2 years
    That was a temporary solution. and while using it like that, after several updates for months, and now I don't get such issue anymore. I don't know why. please comment here if you found the reason :).