Getting gradle errors in a Flutter application after importing packages - flutter

I'm building a Flutter app, and just added the mime and http_parser packages. After that I got the following error when building:
<appname>\build\app\intermediates\merged_manifests\debug\AndroidManifest.xml:35: AAPT: error: resource integer/google_play_services_version (aka com.att.fluttercount:integer/google_play_services_version) not found.
Up until now, the app had built just fine. I backed out my changes, including removing the packages from pubspec.yaml, but the error won't go away.
Here's the relevant part of my pubspec.yaml:
environment:
sdk: ">=2.1.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: ^0.1.2
flutter_map: ^0.5.0+1
scoped_model: ^1.0.1
rxdart: ^0.21.0
flutter_masked_text: ^0.8.0
image_picker: ^0.5.0+9
webview_flutter: ^0.3.6
sqflite: ^1.1.5
http: ^0.12.0+2
#mime: ^0.9.6+2
#http_parser: ^3.1.3
# Must use 'any' as the version of path_provider, because other packages depend on
# earlier versions of path_provider.
path_provider: any
# Note: Must use 'any' as the version of uuid, because some dependencies of flutter_map
# depend on earlier versions of uuid.
uuid: any
dev_dependencies:
flutter_test:
sdk: flutter
Does anyone have any suggestions on how to fix this errror?

I had neglected to mention that I had also removed a dependency on google_maps_flutter, which I was no longer using. I added this dependency back in, and the error went away.

Related

Could not find package flutter_localization in the Flutter SDK

I am currently trying to implement localization in my Flutter App but whenever I try to add the dependency for flutter_localization, I get the following error Message:
Because the timer depends on flutter_localization from SDK which doesn't exist (could not find package flutter_localization in the Flutter SDK), version solving failed.
I have also correctly added the path to both my flutter and dart SDKs in Android Studio.
Here is my pubspec.yaml file:
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
dependencies:
flutter:
sdk: flutter
intl: ^0.17.0-nullsafety.2
cupertino_icons: ^1.0.2
sqflite: any
shared_preferences: ^2.0.15
path_provider: any
flutter_localization:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
I can't access GlobalMaterialLocalizations without flutter_localization and apparently, this is the easiest solution. I have already tried many solutions like checking version compatibilities and updating all dependencies. can you guys help me out?
Thanks in Advance!
Upgrading SDKs, Upgrading Dependencies, reinstalling flutter and Dart, and more
You misspelled the package
Replace
flutter_localization:
sdk: flutter
With
flutter_localizations:
sdk: flutter
Take note on the s on flutter_localizations

Flutter dart null safety migration dont work because of package flutter_template_images

I want to migrate my project to null safety but the dependecie flutter_template_images is not supporting null safety:
Package Name Current Upgradable Resolvable Latest
direct dependencies:
flutter_template_images ✗4.0.0 ✗4.0.0 ✗4.0.0 ✗4.0.0
dev_dependencies: all support null safety.
You are already using the newest resolvable versions listed in the 'Resolvable' column.
Newer versions, listed in 'Latest', may not be mutually compatible.
I dont know where this package comes from and I dont find it in the pubspec.yaml file. Can I migrate null safety without upgrading this dependencie?
EDIT:
This is my pubspec.yaml file:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
material_design_icons_flutter: ^4.0.5955
pdf: ^3.3.0
path_provider: ^2.0.2
provider: ^6.0.0
open_file: ^3.2.1
intl: ^0.17.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
cloud_firestore: ^2.3.0
get: ^4.1.4
printing: ^5.4.3
google_sign_in: ^5.0.5
firebase_auth: ^3.0.1
fl_chart: ^0.36.3
url_launcher: ^6.0.9
sqflite: ^2.0.0+4
It appears the maintainer has not migrated the package to dart-null-safety, you could either wait for the maintainer to migrate the package or clone the package and migrate the package yourself.
Another option could be that you remove the package from your project.
For more clarification dart-null-safety

A problem occurred configuring project ':shared_preferences_linux'

When I add a dependency shared_preferences: ^0.5.8
Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 362
What went wrong:
A problem occurred configuring project ':shared_preferences_linux'.
Could not find method implementation() for arguments [project ':path_provider_linux'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
pubspec.ymal
environment:
sdk: ">=2.1.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: ^0.1.2
shared_preferences: ^0.5.8
dev_dependencies:
flutter_test:
sdk: flutter
You must show the pubspec.yaml file
he problem has been solved, The reason is that the SDK version is too low, v1,12.13+h9 update to 1.17.5

rxdart is not installing in my PC due to some issue in dart SDK version

I'm trying to install rxdart by copying it from https://pub.dev/packages/rxdart/versions/0.7.1#-installing-tab- , but its showing some error.
The current Dart SDK version is 2.3.0-dev.0.5.flutter-a1668566e5.
Because flutter_course depends on rxdart >=0.1.0+1 <0.16.0 which requires SDK version >1.12.0 <2.0.0, version solving failed.
pub get failed (1)
exit code 1
I tried using flutter upgrade.
But that doesn't change anything.
My pubsec.yaml file
version: 1.0.0+1
environment:
sdk: ">=2.1.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: ^0.1.2
scoped_model: ^1.0.1
http: ^0.12.0+2
shared_preferences: ^0.5.3+1
rxdart: ^0.7.1
dev_dependencies:
flutter_test:
sdk: flutter

Flutter Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source. sdk: flutter ^^^^^^^^^^^^^

I keep getting
Running "flutter packages get" in flutter_sportters...
Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source.
sdk: flutter
^^^^^^^^^^^^^
When I run my app or Packages Get.
It worked perfectly fine before. Have no idea how to fix this.
Consider you are going to use this package "shared_preferences".
You will get this error in pubspec.yaml. If you did like below.
dependencies:
flutter:
sdk: flutter
shared_preferences: v0.4.2
Indention is important you are accidentally adding shared_preference package below flutter dependency. So the error "A dependency may only have one source"
Correct format below:
dependencies:
flutter:
sdk: flutter
shared_preferences: v0.4.2 #no indention
It throws an error because of Indention. It is important to maintain Indention while adding a dependency in flutter.
Before :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
After :
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
Hope this will solve your error.
Happy coding!!!
Indentation !!!
Being newbees making silly mistakes. I have written the new dependency inside the flutter root as :
dependencies:
flutter:
sdk: flutter
sqflite:
Instead of
dependencies:
flutter:
sdk: flutter
sqflite:
Comment when you see the difference!!
I was trying to add assets folder to my project. I added it under dependencies which caused the error:
dependencies:
flutter:
sdk: flutter
assets:
- images/
It's not to be added under dependencies. Instead, add it under flutter:
flutter:
uses-material-design: true
assets:
- images/
You can define just like that in pubspec.yaml file
dependencies:
flutter:
sdk: flutter
image_picker: 0.4.1
and flutter packages get you can call via terminal or if you are using Android Studio than options availbale above when you edit pubspec.yaml file.
In terminal go to your project directory and then enter flutter packages get
I solve My problem:
Here my first Code
dependencies
flutter:
sdk: flutter
webfeed: ^0.4.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
after I change it
dependencies:
flutter:
sdk: flutter
webfeed: ^0.4.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I thing you must to put your package name in the same number colunm of flutter: and cupertino_icons:
Check indentations as flutter package in pubspec.yaml takes single dependency source.
make sure, the name of your project is not same as any package ,
this too cause for this error
open your pubspec.yaml file
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
country_code_picker: ^1.0.4
Other answers are correct. I would also like to add that I was trying to add shared_preferences and even though my indentation was correct, I was still getting the error mentioned in the question. To resolve it I changed the name of my project as it was also shared preferences
I kept getting this error no matter what I did, including commenting out the new lines. Finally, I put them back in with the correct indentation and ran the program. The problem magically resolved itself. However, the indentation is critical.
I am getting this error due to duplication of a package in dependencies
i.e:
dependencies:
flutter:
sdk: flutter
**cupertino_icons: ^0.1.2**
english_words: ^3.1.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I solved this error by removing duplication then Flutter clean and then Flutter Packages Get.
Its due to indentation: check out correct way
name: flutter_app
description: A new Flutter application.
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: "0.11.3+17"
autocomplete_textfield: ^1.6.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I ran into the same problem turns out the name of my app and the package name were same which resulted into this error.
name of the app scrapy and the dependency was also scrapy...
Changed the name and it worked.
After checking all other solutions if the problem still persists
make sure whether the specified library is installed correctly or not. This error also encounter when the library is not installed correctly.