flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Home Page:https://flutter.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Target of URI doesn't exist: package:shared_preferences/shared_preferences.dart

zeexan-dev opened this issue · comments

pubspec

screenshot_3

Main

screenshot_4

Flutter Doctor

[√] Flutter (Channel master, v0.3.6-pre.25, on Microsoft Windows [Version 10.0.16299.402], locale en-PK)
    • Flutter version 0.3.6-pre.25 at C:\fluttersdk\flutter
    • Framework revision d8f2f36935 (68 minutes ago), 2018-04-26 09:42:26 -0700
    • Engine revision cb2092b3fd
    • Dart version 2.0.0-dev.50.0.flutter-8d4074175f

[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
    • Android SDK at C:\Users\Muhammad Zeeshan\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 27.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
    • All Android licenses accepted.

[√] Android Studio (version 3.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 23.2.2
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)

[√] VS Code, 64-bit edition (version 1.22.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Dart Code extension version 2.12.0

[√] Connected devices (1 available)
    • TRT L21A • VWD7N17706001493 • android-arm • Android 7.0 (API 24)

• No issues found!

Did you run flutter packages get (without error)?
Have you tried restarting the IDE?

@zoechi ... yeah i did run "flutter packages get" command but it did not solve problem.
I also tried using "flutter clean" and "flutter upgrade" but same result.

Restarting IDE solved this problem

commented

https://pub.dartlang.org/documentation/shared_preferences/0.2.0%2B1/
Try this ^

Just add shared_preferences: ^0.2.0 to your dependencies in the pubspec.yaml file

@ENGR-ZEESHAN I'm going to close this according to your last comment it should be solved.
Just add a comment if you think there are unresolved issues or questions.

I have done everything still its not working..
I'm trying to import :::::"import 'package:socket_io_client/socket_io_client.dart'"
I added dependencies in pubspec.yaml :::: "socket_io: any"..
help me out

@zoechi ... yeah i did run "flutter packages get" command but it did not solve problem.
I also tried using "flutter clean" and "flutter upgrade" but same result.

Restarting IDE solved this problem

restarting IDE also did not solve the problem

Having the same issue

@devoncarew there were several similar reports recently. Do you have any idea?
Deleting la ~/.dartServer/.analysis-driver/ or re-installing Flutter, changing channel, doesn't seem to have any effect.
Anything that might make sense to try?

See also #24279

@zoechi, do you have links to the other reports (other than the one directly above)? From reading the above, they look like separate issues w/ the same symptoms.

We use information in the .packages file to locate package references. People could try either deleting that file and running flutter packages get, or run flutter packages upgrade.

There's some chance that their pub cache is corrupted, in which case they'd want to either delete ~/.pub-cache/hosted/pub.dartlang.org/ and re-run flutter packages get, or try running flutter packages pub cache repair.

@devoncarew I don't have the links. I didn't know what to make from the other reports at the time. It just now starts to look like some pattern. I'll add links when I find them again.

Just in case it might add to a pattern: Running flutter packages pub cache repair just now solved the following problem:
I created an app to start using Firebase and the cloud_firestore plugin caused the Android build, not the iOS build, to crash with, among other errors:

error: package app.google.android.gms.tasks does not exist
error: package app.google.firebase does not exist
error: package app.google.firebase.firestore does not exist 

I have seen issues with the package cache with plugins mentioned as well a few times.
Package cache seems pretty stable except a bit less with plugins.

It's possible that some tooling or user edits reach into the pub cache and modifies files.

I'm using MacOS, had recently updated to Mojave and had recently updated IntelliJ IDEA to Ultimate 2018.3. I had been trying to get it running for ~2 days before stumbling over the fix. Early on there was an iOS problem that I fixed by running "pod update Firebase." I had also tried switching to the dev channel, from beta, then tried "flutter update-packages --force-upgrade", then switched back to beta by first git stashing. By that time, one or more self-inflicted wounds wouldn't surprise me.

This is happening again. I just downloaded Flutter an hour ago on a new device.

[✓] Flutter (Channel beta, v0.11.13, on Mac OS X 10.13.3 17D47, locale en-US)

It appears that in the dart sdk folder, under lib, there's a folder called "_http", but not one called "http" could that be the problem?

@ThinkDigitalRepair Why do you think it matters if there is a _http folder in the SDK or not?

@ThinkDigitalRepair You are not supposed to use packages that start with _ even when the SDK does.
Add http: ... to dependencies in your pubspec.yaml and run flutter packages get

@zoechi oh ok. I thought it was accidental. I have http as a dependency already. It's been in there for a while, but I get this on a new machine, but not my old one...

My old was was a Mac, and I tried 2 Linux installations and I have the issue on the Linux installations only

@zoechi it turns out this isn't an http error, I can't import any non dart:xxx libraries in this particular file

Fixed it. And you were right. Turns out the file in question was part if a package that was also in the project directory, but has its own pubspec.yaml and project structure. I had to cd into it and run flutter packages get from there

@ThinkDigitalRepair glad to hear you figured it out!

@zoechi ... yeah i did run "flutter packages get" command but it did not solve problem.
I also tried using "flutter clean" and "flutter upgrade" but same result.
Restarting IDE solved this problem

restarting IDE also did not solve the problem

Me too!

@alan-knight try flutter packages pub cache repair

If that doesn't work, can you send us your project structure? You can get it from the terminal on Linux or Mac by using the command tree from the root of the project

What OS are you using?

Use the 'tree' command.
Try 'tree -L 3' that'll only show 3 levels deep. We don't need to ENTIRE project. I just want to see if you have any extra projects in your project

It's called tree. It's like ls, but shows the directory structure as a tree

Install home brew for Mac and then use brew install tree

OK. No need. I can see the structure from there. Because you have 2 separate projects, you'll need to get the packages for both of them. from the terminal, in the root directory, run these commands.

cd mobile
flutter packages get
cd ../web
flutter packages get

after that, it should have all the packages for both projects and should run fine.
For anyone else following this, change the part after cd with the path to your project. You'll know if it's the right directory because it should have a pubspec.yaml file in it.

In web you should use pub packages get instead of flutter packages get.
You can delete ios/ and Android/.

I couldn't find a reference to shared_preferences in https://github.com/NoipyDevOPS/Dart-Noipy
How is this related to this issue?

commented
Xcode build done.                                            1.7s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Release ===
    Could not find an option named "track-widget-creation".

    Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
    Failed to build /Users/xxx/unity_flutter.
    Command /bin/sh failed with exit code 255

Encountered error while building for device.

In web you should use pub packages get instead of flutter packages get.
You can delete ios/ and Android/.

I couldn't find a reference to shared_preferences in https://github.com/NoipyDevOPS/Dart-Noipy
How is this related to this issue?

How can I remove ios/ and Android/ folder inside web ?

@Allan-Nava what exactly is this web/?
How is it related to Flutter? Is this a Flutter project?

@Allan-Nava how did these directories there in the first place then?

These directories should only have been created if you run flutter create ....
If you just delete them they shouldn't be recreated.

Add
http: any
to pubspec.yaml file under dependencies
inside the project directory

I was using shared_preferences fine, but when I added new dependency above it in pubspec.yaml this problem ocurred. When I positioned that newly added dependency below shared_preferences the problem dissappeared.

@temirfe I'd suggest to post a question on StackOverflow with your pubspec.yaml

For me, the error was on my side: I changed the name of the app in the pubspec.yaml:

name: mobile_app # Before
# name: Mobile App # After, and it didn't work

Guys,
Solved same issue with this
Run this:

flutter packages pub cache repair

Just Do Restart IDE that's it.

Restart vscode or run Reload Window solved the problem, but it's weird. More intelligent Flutter plugin will be appreciated.

restarting IDE results in solving this error.

flutter pub cache repair and Invalidate and Restart IDE solved my issue.

commented

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.