简体   繁体   中英

firebase_analytics 0.0.4 which requires SDK version >=1.8.0 <2.0.0, version solving failed

I am trying to learn mobile devt using flutter, dat and firebase. SO as a start I downloaded the chat app code from here

But I can't seem to run the code via vscode and android studio. Can anyone please help me figure out how to run this.

error is: VScode:

{ "resource": "/C:/Users/Administrator/Downloads/flutter-chat-app-master/flutter-chat-app-master/lib/ChatMessageListItem.dart", "owner": "dart", "code": "uri_does_not_exist", "severity": 8, "message": "Target of URI doesn't exist: 'package:firebase_database/firebase_database.dart'.\\nTry creating the file referenced by the URI, or Try using a URI for a file that does exist.", "source": "dart", "startLineNumber": 1, "startColumn": 8, "endLineNumber": 1, "endColumn": 58, "tags": [] }

this is the error when i run it in android studio.

C:\\src\\flutter\\bin\\flutter.bat --no-color packages get Running "flutter packages get" in flutter-chat-app-master... The current Dart SDK version is 2.3.0-dev.0.5.flutter-a1668566e5.

Because flutter_chat_app depends on firebase_analytics 0.0.4 which requires SDK version >=1.8.0 <2.0.0, version solving failed. pub get failed (1)

I was able to run other sample codes, one is from this so I know that my setup is working.

I already tried few possbile solutions but not working, I saw this , but did not solve my issue.

I think the error requires me to downgrade android sdk but I dont know where to do that. I just need to run so I can see what it looks and I can follow. thanks.

You are using SDK version 2.3 and the package firebase_analytics 0.0.4 requires SDK version >=1.8.0 <2.0.0.

Some dependencies of this project are out of the date.

  cupertino_icons: ^0.1.2
  firebase_auth: 0.7.0
  google_sign_in: 3.2.4
  cloud_firestore: 0.8.2+3
  fluttertoast: ^2.0.7
  image_picker: 0.4.12+1
  shared_preferences: 0.4.3
  firebase_storage: 1.0.4
  cached_network_image: ^0.7.0
  intl: ^0.15.7

Update all of them to the newest version.

After a lot of googling , reinstalling, downgrade, upgrade, package get(which never worked coz the error was in the way so it exits before it could 'get'), package upgrade etc, I was finally able to solve this.

The only problem I had was I did not know which version (or what is the latest) to use coz for some reason, it wasn't indicated in their list of "versions", or least it wasn't easy to find coz I always end up in this page . Simply putting these lines (and/or doing the answer above)

environment:
  sdk: '>=2.1.0 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
    google_sign_in: ^0.3.1
    firebase_analytics: ^0.0.4
    firebase_auth: ^0.2.0
    firebase_database: ^0.0.12
    firebase_storage: ^0.0.5

in yaml did not solve it, although a lot of ppl claimed it did.

the only thing that solved it was when I happen to go in this page where it contains the correct and latest firebase versions that the latest Dart SDK where in my case - DART SDK 2.3 supports. just get the current version to this You can search every plugin in the search bar.

my yaml looks like this now:

dependencies:
  flutter:
    sdk: flutter
  image_picker: ^0.6.0+8
  google_sign_in:  ^4.0.1+3
  firebase_analytics: ^3.0.1
  firebase_auth: ^0.11.1+1
  firebase_database: ^3.0.0
  firebase_storage: ^3.0.0

Added steps which I am not sure if it is necessary, but I did it before the version correcting.

  1. invalidate cache, restart In relation with running the app itself, and not particular to firebase:
  2. change gradle version by doing steps from here (because of some error with gradle not related to firebase) and look for answer of keviepanas

Fixed: i got thesame issue as when trying to run flutter upgrade, have tried all the fix online nothing seems to be working, all i deed was upgrade manually and boom, everything worked like magic 1.Download the latest stable version from https://flutter.dev/docs/get-started/install/windows 2.then copy the extracted folder to your flutter directory, 3 delete all files from your previous flutter directory, and paste in the current files from the latest release Note: do not delete the flutter sdk directory folder, of cause you cant cause it is already in use. Summary: all you need do is download the latest version and replace the content(files)with your old flutter sdk files and you are good to go

This combination is working


environment:
  sdk: ">=2.1.0<3.0.0"


dependencies:
  firebase_core: ^0.3.4
  firebase_auth: ^0.8.4+5
  cloud_firestore: ^0.9.13+1
  flutter:
    sdk: flutter




Just try one of the previous versions. The latest one which is dev version is not worked for me. Using an old version worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM