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

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)

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

Flutter ImagePicker library cannot be found

Im trying to implement ImagePicker to my Flutter project but when i try to import the package: import 'package:image_picker/image_picker.dart'; it only shows error. I have added it to my pubspec.yaml file as a dependecie but it displayed this error when I reopened the VS:
Because LPP requires SDK version >=2.12.0 <3.0.0, version solving failed.
pub get failed (1; Because LPP requires SDK version >=2.12.0 <3.0.0, version solving failed.)
exit code 1
This is my pubspec.ymal file:
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
image_picker: ^0.7.2+1
So any help would be great. Thanks in advance :) <3
Which flutter- and dart-version shows "flutter doctor -v"?
Your sdk has to be >= 2.12
If you don't use flutter 2 with dart 2.12 than upgrade flutter (I have currently massive problem with this) or downgrade the versions of sdk, Cupertino-icons and image-picker in the pubspec.yaml-file
Ok so I changed version from 7.2+1 to 6.2 and now it works. :)

Running Gradle task 'assembleDebug'. (This is taking an unexpectedly long time.)

when I created a very basic flutter app and ran it for the first time, it works perfectly, and when I try to add some dependencies in my pubspec.yaml file I get no errors in my project but when I run the app by 'flutter run' I get stuck in
Running Gradle task 'assembleDebug'...
(This is taking an unexpectedly long time.)
and the app has never worked
this is my pubspec.yaml file
name: myPDFApp
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
syncfusion_flutter_pdfviewer: ^18.4.35-beta // this is the dep that I want to add
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Add an earlier version of the dependencies, and run pub get. This could solve the issue

Can't run the flutter app after added firebase-core and auth to the project

Here's the error in console, plus flutter doctor didn't showed any error. I've tried upgraded the android sdk to 28, check build.gradle. It still don't work and I have no clue.
Error
Pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
google_fonts: ^1.1.1
path_provider: ^1.6.24
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
1- Move them to dependencies
2- Leave a space at the beggining of the dependencie name like so:
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.5.1
firebase_auth: ^0.18.2
google_fonts: ^1.1.0
provider: ^4.3.2+2
If you realize, it's like if flutter and the rest of your dependencies were at the same level
Its AAPT issue;
Open this open C:\Users\user\Desktop\Projects\Flutter\eLesson\android\app\src\main\AndroidManifest.xml and remove style/Theme.AppCompat.Light.NoActionBar
and
your App or some of you plugin is not compatible to AndroidX. Open android folder of your project in separate Android Studio. Right click on Project->Refactor->Migrate to AndroidX.
Repeat this process for each of your plugin folder.
Clean and Rebuild.
Enjoy.

rxdart usage in Flutter not being recognized

I am trying to use rxdart package for the first time in my Flutter app and I have added the package in yaml file, then I saved it and vscode automatically ran flutter packages get on project after that complete I tried to import the package with following line
import 'package:rxdart/rxdart.dart';
but the compiler doesn't recognize rxdart within the packages. which is causing the error in the app.
The following are my dependencies of pubspec.yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
rxdart: ^0.18.0
dev_dependencies:
flutter_test:
sdk: flutter
Update
Here is the repo for the project I am working on: https://www.github.com/touseefbsb/LoginStateful
You have to open the folder login_stateful_bloc and the error is in bloc.dart file where I am trying to import it.
You have to keep the indents :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
rxdart: ^0.18.0
I was having the same issue. Even after pub get, it didn't work. Then I simply restarted my IDE(Android Studio) and now it works.
this worked for me, make sure you putted the dependencies on
dependencies:
flutter:
not
dev_dependencies:
flutter_test:
if that make sense :/

built_value has a dependency conflict with flutter_test

I'm trying to fetch JSON data using built_value serializer but after setting built_value package in yaml file getting an error like:
Because built_value_generator >=5.5.3 depends on analyzer ^0.32.1 and
every version of flutter_test from sdk depends on analyzer
0.31.2-alpha.2, built_value_generator >=5.5.3 is incompatible with flutter_test from sdk. So, because tornado_blog_flutter depends on
both flutter_test any from sdk and built_value_generator ^5.5.3,
version solving failed. pub get failed
How to solve this error?
My yaml file:
name: flutter_layout
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
built_collection: '>=2.0.0 <4.0.0'
built_value: ^5.5.3
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
json_serializable: ^0.5.0
build_runner: ^0.9.0
built_value_generator: ^5.5.3
There's some info on this issue here. The version of analyzer used by Flutter needs to be upgraded to solve this.
There's an open issue in Flutter to this here but it doesn't seem to have been done yet.
As a workaround, you could try going back to an earlier version of built_value that doesn't require such a new version of the analyzer.

Categories

Resources