Flutter "packages get" failes with error "Couldn't read file LocalFile..."

Viewed 1112

I have a Flutter project and from one day to another I could not run packages get anymore. It failes with:

Couldn't read file LocalFile: 'LOCAL_FLUTTER_SDK_PATH\flutter.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.6\android\src\main\kotlin\io\flutter\plugins\flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.kt' even though it exists. Please verify that this file has read permission and try again.

Also building the app is since that moment not possible anymore, it failes with the same error.

My pubspec.yaml:

name: my_app
description: My fancy cross plattform app

version: 1.0.0+2

environment:
  sdk: ">=2.3.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  flutter_cupertino_localizations: ^1.0.1
  http: ^0.12.0+2
  sqflite:
  path:
  crypto: ^2.1.3
  flutter_typeahead: ^1.7.0
  image_picker: 0.3.0
  google_maps_flutter: any
  http_parser: ^3.1.3
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  intl_translation: ^0.17.7

flutter:
  assets:
    - assets/
    - assets/img/

  uses-material-design: true

Note that I created a new project just with the same pubspec.yaml file and there everything works fine. If you have any idea which in my project could cause this error, please tell me I will add that source code then, because the pubspec.yaml seems not to be the reason or at least not the only one.

I have the newest Flutter version (v1.12.13+hotfix.8)

1 Answers

I faced a similar issue. Whenever I run, flutter pub get, I got the following error

flutter Couldn't read file LocalFile: .... flutter_plugin_android_lifecycle\FlutterAndroidLifecyclePlugin.kt' even though it exists. Please verify that this file has read permission and try again.

So, I run these two commands:

flutter clean
flutter pub cache repair

While running the second command, I noticed this new issue:

Failed to repair flutter_plugin_android_lifecycle 1.0.7. Error: FileSystemException: Deletion failed, path = ...\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.7' (OS Error: The system cannot find the path specified.

Then, following this Packages GET failes with The plugin flutter_plugin_android_lifecycle, I removed the .pub-cache folder in my flutter directory

After that, I run

flutter pub get

Finally, everything starts to work again.

Related