Android Studio doesn't find CocoaPods when the package flutter_inappwebview is added to pubspec.yaml. It complains that CocoaPods is not installed. But I can still build and run the app from the console with flutter run.

The minimal project to illustrate this bug is in https://github.com/kvutien/my_inappwebview

Any idea why?

My development configuration

  • Macbook Pro with M1 Pro chip and macOS 12.1 Monterey
  • flutter doctor output:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-LU)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Connected device (2 available)

• No issues found!

How to reproduce the bug

  • In Android Studio, create New Flutter Project
  • Set the SDK used in File > Project Structure > Project > Project SDK, select Android API 32
  • Select an iOS virtual device
  • Run the app to prove that it works, from the box.
  • open pubspec.yaml add the following line to the section dependencies (that should be at line 29 of the template code), immediately below sdk: flutter,
  flutter_inappwebview: ^5.3.2
  • run pub get to update the dependencies
  • run the app with the Run buttton

Android Studio will complain

Launching lib/main.dart on iPad mini (6th generation) 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 see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

CocoaPods not installed or not in valid state.
Error launching application on iPad mini (6th generation).

Build and run still possible from Android Studio's Terminal

It's not a problem with missing CocoaPods, nor of missing PATH in configuration.

Without changing anything in the code, open the Terminal pane of Android Studio and type flutter run. The build will succeed and the app will run in the virtual device.

Launching lib/main.dart on iPad mini (6th generation) in debug mode...
Running Xcode build...                                                  
 └─Compiling, linking and signing...                      2,243ms
Xcode build done.                                            8.5s
Syncing files to device iPad mini (6th generation)...               56ms

But Android Studio behaves well, see sample flutter_inappwebviewer project in pub.dev

No need to run from the Terminal.

To prove it:

  • In Android Studio, create New Flutter Project
  • Set the SDK of the project as above
  • Select an iOS virtual device
  • Replace the initial main.dart with the sample code in pub.dev
  • Add the dependency in pubspec.yaml
  • Run pub get
  • Build and run the app with the Run buttton

Android Studio will not complain about CocoaPods with this code.

The project to illustrate this is in https://github.com/kvutien/test_in_app_webview

Any explanation is welcome.


Solution 1: Khang Vu Tien

Problem solved on February 11, 2022.

The Android Studio upgrade Bumblebee 2021.1.1 Patch 1a for macOS M1 made the bug disappear. Running the build from the IDE Run button doesn't produce anymore the CocoaPods missing error message.