22

I am trying to build a Flutter app with Geolocator plugin on Android Studio. When I am running the app I have the following warning - that prevents the app from running:

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 see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

Exception: CocoaPods not installed or not in valid state.

I tried every solution i found in the internet (Stackoverflow & GitHub) but nothing seems to work.

Important: When I tried to run the app from Xcode instead of from Android Studio, I had this error:

The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

So what I did was - Change directory to ios (on the Flutter project) and running:

pod init pod install 

Tried to run again from Xcode and it worked perfectly. After it works on Xcode I tried to run it from Android Studio and the same error happens to me, preventing the app to launch.

Flutter Doctor:

[✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en-IL) • Flutter version 2.2.2 at /Users/idanrefaeli/Developer/flutter • Framework revision d79295af24 (5 weeks ago), 2021-06-11 08:56:01 -0700 • Engine revision 91c9fc8fe0 • Dart version 2.13.3 [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/idanrefaeli/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264) ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1, Build version 12E507 • CocoaPods version 1.10.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264) [✓] VS Code (version 1.57.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.23.0 [✓] Connected device (2 available) • Idan’s (mobile) • 00008020-0011092101A2002E • ios • iOS 14.6 • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114 ! Doctor found issues in 1 category. 

Extra logs: 'Run' log in Android Studio: pastebin.com/7iYtdcTQ Also this terminal log after running 'pod install': pastebin.com/1cCNuFYM

-- UPDATE --

I finally was able to run the app, all I did was to copy all the project files to a new project from scratch and it worked. Maybe some conflict caused this issue, it was my last resort of course.

5
  • 1
    I had the same problem using VS Code, but it was resolved when I reopened it. Commented Jul 19, 2021 at 21:41
  • I tried reopening, restarting, flutter clean, everything Commented Jul 20, 2021 at 14:44
  • Show us the complete error (print) please. I'm trying to reproduce it. Commented Jul 21, 2021 at 3:43
  • Here: pastebin.com/7iYtdcTQ Also this terminal log after running 'pod install': pastebin.com/1cCNuFYM Commented Jul 21, 2021 at 17:19
  • The same problem(( Commented Sep 9, 2022 at 10:57

17 Answers 17

38

In the app Terminal after opening the Simulator write

flutter run 

in the Terminal

or close Android Studio and open terminal and paste

open /Applications/Android\ Studio.app 

it will open the Android Studio and you can run as normal

Sign up to request clarification or add additional context in comments.

4 Comments

this: open /Applications/Android\ Studio.app worked for me
This one really helps, no need to install the patch 1 for Android Studio Bumblebee, just run open /Applications/Android\ Studio.app
Quit the android studio and execute open /Applications/Android\ Studio.app in terminal. started working !
open /Applications/Android\ Studio.app works like charm, thanks!
31
# uninstall sudo gem uninstall cocoapods brew uninstall cocoapods # reinstall sudo gem install cocoapods pod setup # rebuild flutter build ios 

Then, restart vscode and iTerm (it is important), and debug

2 Comments

Finally fixed my issue using these commands +1
most complete and simple answer. +1
11

This error started appearing in mac os after the update

Android Studio Bumblebee | 2021.1.1 Build #AI-211.7628.21.2111.8092744, built on January 19, 2022 Runtime version: 11.0.11+0-b60-7590822 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 12.0.1 GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 8 Registry: external.system.auto.import.disabled=true Non-Bundled Plugins: com.bloc.intellij_generator_plugin (3.3.0), Dart (211.7798), andrasferenczi.dart-data-plugin (0.2.0), com.thoughtworks.gauge (211.6693.111), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), io.flutter (63.2.2), org.intellij.plugins.markdown (211.7142.37) 

In my case, it is working to launch project in vs code, or running project with command flutter run

Android Canary last version solved problem

Update: As Ascot Harris mentioned, Android Studio Bumblebee | 2021.1.1 Patch 1 solves problem

1 Comment

Android Studio Bumblebee | 2021.1.1 Patch 1 solved the issue for me
6

STEP 1: close Android Studio

STEP 2: open terminal

STEP 3: paste:

open /Applications/Android\ Studio.app 

STEP 4: Android Studio will be opened auto.

STEP 5: click run button

Comments

4

I had the same problem and I installed cocoapods and it works now.

Just copy and paste this line to install cocoapods: sudo gem install cocoapods

Restart VSCode and terminals.

And then run your app.

I'm working on MAC with IOS (Iphone 13) emulator.

CocoaPods Guide.

Comments

4

just open terminal and write

sudo gem install cocoapods 

this solve problem in my case

Comments

3

first of all you should do this command below:

sudo gem install activesupport -v 6.1.7.6 

then:

sudo gem install cocoapods 

Comments

3

I could resolve my case by restarting with Invalid Caches in Android Studio.

enter image description here

If you can't resolve to do the above you can try to do the below.

  1. Delete Xcode caches
rm -rf ~/Library/Caches/com.apple.dt.Xcode/ 
  1. Delete intermediate files
rm -rf ~/Library/Developer/Xcode/DerivedData/ 

1 Comment

This works well for new Xcode 16 RC with IntelliJ Idea, thanks
1

for me closing and reopening the VS code fixed the problem.

1 Comment

wow this fixed it for me as well, thanks!
1

This is solved by deleting

Podfile.lock pods folder

updating these packages

firebase_core: ^1.12.0 firebase_analytics: ^8.3.4 firebase_crashlytics: ^2.3.0. firebase_messaging: ^11.1.0. 

then running first

pod repo remove trunk

and finally

pod install 

Comments

0

This is a horrible hack, which sometimes works.

I run the app from Visual Studio code once and the subsequent run in Android Studio work

Comments

0

As @islomkhuja-akhrarov mentioned it's an Android Studio Bumblebee problem, installing patch 1 helped

Comments

0

I guess that the fault lies among these particular dependencies on ios side:

firebase_core: firebase_messaging: 

My setup: MacBook Pro, M2, 2022. VS Code IDE. Flutter 3.19.0, cocoapods 1.15, ios simulator running ios 17.5

Solution

  1. In the Flutter project folder, delete podfile.lock and Pods folder, both of these are present inside ios folder.

  2. Open a terminal window(not in the IDE) and run this command:

    brew install cocoapods

    It runs many downloads for a while (20 minutes in my case).

  3. From the same terminal run:

    pod setup

  4. Now go to the Flutter project folder, open a terminal in it, and run the following commands (not necessarily in a chain):

    flutter clean && flutter pub get && cd ios && pod repo remove trunk && pod install && pod repo update && cd .. && exit

After doing the steps above, I still got the same error during the build. I got frustrated, force-closed every open window/app, and rebooted the system.

I took a break and ran the project again, and the error no longer appeared.

I can't pinpoint it, but something above definitely worked.

Comments

0

I had the same problem, and I found this simple solution that worked for me.

  1. Open project in XCode (if you're using VS Code, right click on the iOS folder and selec 'Open in XCode')
  2. Go to Runner->Signing&Capabilities and choose a team (make sure the team includes your device if it's a physical iOS device)
  3. Run your project from XCode

Comments

0

I ran

sudo gem install cocoapods 

And then restarted Android Studio.

Comments

0

I had to uninstall cocoapods from gems and HomeBrew:

sudo gem uninstall cocoapods brew uninstall cocoapods 

Then, use brew to install:

brew install cocoapods 

After this, restart your IDE and or Terminal.

Comments

-1

It can also be the case if your updating the xcode so wait till the installation complete

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.