How to resolve Firebase AdMob Integration problem - flutter

I am trying to add AdMob ads to my Flutter app. For that, I tried using firebase_admob (^0.9.3+2) plugin but it's not working for me, it stuck at build.apk.
I am getting the output as :
Note: /home/abhishek/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_admob-0.9.3+2/android/src/main/java/io/flutter/plugins/firebaseadmob/AdRequestBuilderFactory.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
My dependency in pubspec.yml are :
dependencies:
flutter:
sdk: flutter
meta: ^1.1.8
platform: ^2.2.1
firebase_core: ^0.4.0+9
firebase_analytics: ^5.0.2
firebase_admob: ^0.9.3+2
Where am I doing wrong?

See if you can remove firebase_core: ^0.4.0+9 then exec flutter clean

Not sure if it is related or not, but I'm having problems adding dependencies:
Error: Could not resolve the package 'google_sign_in' in 'package:google_sign_in/google_sign_in.dart'.
lib/authsvc.dart:7:8: Error: Not found: 'package:google_sign_in/google_sign_in.dart'
import 'package:google_sign_in/google_sign_in.dart';
I'm able to add the dependency in the pubspec.yaml file, run 'pub get' and it says that it downloads fine. No errors are reported in the editor (i.e. it recognizes the new commands and doesn't flag them). However, when I try to compile/build it, I get the above error message. 'Pub get' worked fine until I upgraded to the latest version of Flutter (v. 1.17.3) before I believe I was on (v. 1.17.0).
To fix it, I hardcoded the path in the Dart_Packages.xml file.
(I'm not looking to troubleshoot further, just adding this in case it helps the developers identify the problem). Thanks!

Related

Integration failed when run

I try to solve this problem. My integration test failed when I add the latest package. The error 'vm_service does not support' when I add the latest version. So I try to use integration_test 0.8.1. This package ok but when I try to run flutter show this error. Can't someone help me?
In docs was said:
This package has been moved to the Flutter SDK. Starting with Flutter 2.0, it should be included as:
dev_dependencies:
integration_test:
sdk: flutter
Why you are trying to set up integration_test?

The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'

Recently I've updated to flutter 2.5 and the newest androids studio, and tried to compile my flutter project to android device. Android studio throws me the error below. If I write flutter run in a terminal there is no problem compiling to android device.
Guess this must be related to android studio. I tried downgrade to an earlier android studio version, but the problem persists.
I'm not sure what plugin this is, it doesn't seem like any I use in my project.
Edit: If I downgrade flutter from 2.5 to 2.0 my project compiles again. So the problem is within flutter 2.5
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
../plugins/flutter/.pub-cache/hosted/pub.dartlang.org/photo_view-0.11.1/lib/src/core/photo_view_gesture_detector.dart:106:29: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
- 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
- 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
super.addAllowedPointer(event);
There was an API change in version 2.5 of flutter and several packages must update accordingly.
Your logs show that the exact package which contains the error is photo_view.
Luckily enough the package has just been updated to fix this, so just update its version in your pubspec.yaml:
photo_view: ^0.12.0
UPDATE
If you don't have the package directly in your pubspec
You have two options
1 It's probably a transient dependency, you can run flutter pub deps
to list the installed packages and its dependencies and try to update the one that uses photo_view (if it does have an update)
2 Add a dependency override to your pubspec.yaml, this will effectively override the version of the package being used
dependency_overrides:
photo_view: ^0.12.0
Add this just before your dev_dependencies
from your debug code
('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
you open the file or click if there are link clickable
Search for this:
void addAllowedPointer(PointerEvent event) {
and replace with this:
void addAllowedPointer(PointerDownEvent event) {
Here is the reference link
https://flutter.dev/docs/release/breaking-changes/gesture-recognizer-add-allowed-pointer
This problem arises due to the GestureRecognizer Cleanup -
Here is the documentation if you are intrested in the migration code
But in case you just want to build your flutter app without any migrations following are couple of solutions to that problem
You can update photo_view dependency in your pubspec.yaml file to
photo_view :^0.12.0
If you do not want to update your dependency due to any reason you can opt for this temporary fix . In the pubspec.yaml file add the following custom photo_view with better gesture recognition in dependency_overrides.
dependency_overrides:
photo_view:
git: git://github.com/robertodoering/photo_view.git

im unable to package get the package "english words" in pubspec.yaml

I'm unable to get the required package English_words.
under dependencies I added English_words: ^3.1.5
screenshot of "pubspec.yaml" file with execution:
Edit: Issue resolved, importing package worked fine. The full code is also given in the flutter docs.
I suspect you are following the tutorial at https://flutter.io/docs/get-started/codelab#step-2-use-an-external-package ... the "+" in front of english_words there is an indicator of a diff. You should add that line, but leave off the +.
I found error in pubspec.yaml file as shown in your screenshot. You need to add english_words: ^3.1.5 to dev_dependencies rather than in dependencies. Actual code snippet will be:
dev_dependencies:
flutter_test:
sdk: flutter
english_words: ^3.1.5
Then click on Package get (shown in Android Studio) option to add above dependency for the project. You can also do the same using command(in project stucture):
flutter packages get

Because every version of flutter_test from sdk depends on... flutter_test from sdk is forbidden, version solving failed

I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?
If you get the message:
Because every version of flutter_test from sdk depends on...
It means flutter_test depends on a dependency with version lower than you specified in another dependency.
To solve this, open pubspec.yaml, and remove the version number of the problem dependency:
Example:
Change
archive: ^2.0.13 --> remove this number
To:
archive:
You have provided or trying to use http: ^0.12.0 dependency on implementing API calls in pubspec.yaml file but flutter_test will require http: ^0.11.3+17. That's why it fails. Please replace
dependencies:
flutter:
sdk: flutter
http: ^0.12.0
with
dependencies:
flutter:
sdk: flutter
http: ^0.11.3
Hope it will help you out.
In my case, I somehow deleted sdk: flutter:
dependencies:
flutter:
sdk: flutter
I was facing a similar error. I solved it by removing all the version numbers from the dependencies: section in pubspec.yaml.
So, if my pubspec.yaml looked like this before:
dependencies:
freezed_annotation: ^0.14.3
I changed it to this:
dependencies:
freezed_annotation:
I'm assuming this fetches the latest "possible" version of each package.
Can you please provide the dependencies in your pubspec.yaml? It looks like your app depends on at least http 0.12.0 but flutter_test specifically requires http 0.11.3+17 (an older version) which makes it fail.
If your app doesn't have too many dependencies that could broke, you can try to upgrade your Flutter version: flutter upgrade.
It most probably will fix this problem. But always be sure to understand that your app might break at unexpected places.
So you're fine if:
either you're doing it for small app
or it's big app at work and it has extensive tests that will tell you something has broken
if big app without tests, be sure to test every important place of the app, where dependencies are being used
Try to change the dependency version that you were added in your pubspec.yaml file
don't use the current or latest version try some previous versions of dependency.
for ex - if you are using latest sqflite version then chnage to previous version of that and then re-run your whole project.
In my case IDE referred to an an older version of dart because of fvm. Seems like 'run' button called fvm flutter run, but not flutter run as I expected. After I deleted fvm folder from the project the problem has gone.
Change depending attributes version inside pubspec.yaml
if it says depands on http *** than change http version
or if it says depands on collection *** than change collection version.

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

I'm learning to use Flutter using Android Studio. I'm going through step by step doc provided by Flutter. At Step:2 Use an external package I'm getting issue importing the english_words package. I have properly added the package in pubspec.yaml and clicked Packages Get which added the dependency but at the time of importing the package in lib/main.dart it is saying
Target of URI doesn't exist
'package:english_words/english_words.dart'.
I have seen many questions on StackOverflow but none of them helped me. Please help!
For some packages, once you do all the process described by the other answers to this question, you have to close the Android project and open it again. As well as the emulator.
Some packages need the restart, others do not need it.
After adding the package in the pubspec.yaml file, you need to execute the command flutter packages get or click on "Packages Get" in the action ribbon at the top of pubspec.yaml file.
Then the dependency and any transitive dependency will be added to the .packages file.
Check this:
https://flutter.io/using-packages/
Solution (For VSCode):
Run flutter packages get in pubspec.yml
Restart VSCode
I had the same issue and went about it like listed below and it worked.
1. Add the package
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
**english_words: ^3.1.5**
Save the pubspec.yaml file
go to your terminal and run 'flutter packages get'
4.Close your simulator and rebuild your cradle
Run the main.dart again and it should remove the error.
This is what worked for me, all the best.
Make sure that english_words is on the base-line with flutter:
Took me a lot of time, but in summary, just save the file pubspec.yaml will do. The command flutter pub get will be ran once u save it, then u can import the package.
There is no need to restart ur editor etc.
My solution was to add the "english_words: ^3.1.5" the version at the moment that I write this, under the "dependencies:" and before the "Flutter:" argument, without the "+" sign.
Hope that helps
I used this and it worked for me... without + sign and version in double quote ""..
english_words: "^3.1.5"
Make Sure that the alignment of english_words is correct inside your pubspec.yaml as it's "space sensitive" :
dependencies:
english_words: ^3.1.5 //two spaces
also never align it using tabs, I don't know why but it never works, and don't use + sign
There are so many methods to solve this issue, most of them will get solved on the second step,if not please try third method also it will work.
Run flutter packages get in pubsec.yaml file (if you are using VS Code it will be easier).
Restart your IDE.
Check it now, mostly it will work. If not try third step.
you have to repair pub caches
flutter packages pub cache repair
I hope it will work. if all methods are not working try to re install flutter.
my friend solution is so simple only add this code line in file pubspec.yaml
english_words: ^3.1.0
like this
dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
english_words: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
it would work perfectly:)
I faced the same issue but I managed to solve it using the steps below:
add the package as an example english_words: ^3.1.0" in 'pubspec.yaml file.
save file or press ctrl+s
//the Output Console will appear this message
[app name] flutter packages get.
Running "flutter pub get" in first_app..., 2.4s
exit code 0.).
3. check main.dart file, the error will be removed.
For me nothing worked. Things resolved only after
Flutter upgrade
in pubsec.yaml file
For those who are still experiencing this problem, it took me hours to figure out what was wrong. Basically, if all the other answers don't work:
Open the test/.packages file on whatever IDE you are using
Locate the package that is not working and go to that directory on your computer.
Delete the whole package. In my case it was the whole english_words package folder.
In the pubspec.lock and .packages file, delete all instances of that package.
run pub get
In the docs of https://flutter.dev/docs/get-started/codelab there is the following code:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
+ english_words: ^3.1.5
The thing which is causing the error is "+ sign". I just removed it and all worked fine for me.
Delete the plus sign "+" in front of english_words (if you have one)
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^3.1.5
I got the same issue.
It is observed only in version 4.0.0 .For lower versions there is no problem.
So here is what you can do to solve this:
Download code for the dependency from :
https://github.com/filiph/english_words
Unzip it Rename it to
english_words-4.0.0
Copy this folder.
Now go to flutter's SDK folder and navigate to
.pub-cache\hosted\pub.dartlang.org
and paste the folder english_words-4.0.0 here. Add dependency in pubspec.yaml file. Now run flutter pub get command.
You are good to go.
Note : How to find the path of Flutter SDK
All you need to do is to restart IDE(Android studio or VSCode)
Having this error message:
Error: Cannot run with sound null safety, because the following
dependencies don't support null safety:
package:english_words
I had to change this dependency english_words: ^3.1.5 to the latest version english_words: ^4.0.0 and make "pub get":
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^4.0.0
provider: ^6.0.0
in your pubspec.yaml file, instead of:
english_words: ^4.0.0
try:
english_words: '4.0.0'
it worked for me