Flutter firebase version conflict firebase messaging - firebase

I have a firebase flutter app, everything worked, but when I added firebase_messaging: ^5.1.4. The app gives this:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[18.0.
0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:18.0.0 -> com.google.firebase:firebase-iid#[18.0.0], but fire
base-iid version was 19.0.0.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends on project 'firebase_messaging' which depends onto com.google.firebase:firebase-messaging#18.0.
0
-- Project 'app' depends onto com.google.firebase:firebase-core#17.0.0
-- Project 'app' depends on project 'cloud_functions' which depends onto com.google.firebase:firebase-functions#17.0.0
-- Project 'app' depends on project 'firebase_core' which depends onto com.google.firebase:firebase-core#16.0.9
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
uild.gradle file.
These are my other packages
firebase_auth: ^0.11.1+12
firebase_storage: ^3.0.4
cloud_firestore: ^0.12.7+1
cloud_functions: ^0.4.1+1
(they all work)
I have this in my build gradle: classpath 'com.google.gms:google-services:4.2.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
Is there a way of fixing this?
Thank you very much!

I'm currently trying this:
in the app level build.gradle I have this:
apply plugin: 'com.google.gms.google-services'
I'm adding this:
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
(after apply plugin: 'com.google.gms.google-services')

Include Firebase Core dependency in pub spec.yaml and not specifying the versions of firebase dependencies resolve most of the issues.
https://pub.dev/packages/firebase_core

run these two lines
rm Podfile.lock
pod install --repo-update
these will does the job. it took my two days to fix it

Related

react-native build failed after installing admob module

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1001 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Configure project :react-native-firebase_admob
:react-native-firebase_admob package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/admob/package.json
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_admob:firebase.bom using default value: 26.3.0
:react-native-firebase_admob:ads.consent using default value: 1.0.6
:react-native-firebase_admob package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/admob/package.json
:react-native-firebase_admob:version set from package.json: 10.5.1 (10,5,1 - 10005001)
:react-native-firebase_admob:android.compileSdk using custom value: 29
:react-native-firebase_admob:android.targetSdk using custom value: 29
:react-native-firebase_admob:android.minSdk using custom value: 16
:react-native-firebase_admob:reactNativeAndroidDir /home/muhamed-kveshkshaano/suck/node_modules/react-native/android
> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 26.3.0
:react-native-firebase_app:play.play-services-auth using default value: 19.0.0
:react-native-firebase_app package.json found at /home/muhamed-kveshkshaano/suck/node_modules/#react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 10.5.0 (10,5,0 - 10005000)
:react-native-firebase_app:android.compileSdk using custom value: 29
:react-native-firebase_app:android.targetSdk using custom value: 29
:react-native-firebase_app:android.minSdk using custom value: 16
:react-native-firebase_app:reactNativeAndroidDir /home/muhamed-kveshkshaano/suck/node_modules/react-native/android
> Task :react-native-firebase_app:compileDebugJavaWithJavac
> Task :app:processDebugResources FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
37 actionable tasks: 29 executed, 8 up-to-date
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/home/muhamed-kveshkshaano/.gradle/caches/transforms-2/files-2.1/820765fbb4c63d086027395fb7f0dacc/play-services-ads-lite-19.6.0/AndroidManifest.xml:27:5-38:15: AAPT: error: unexpected element <queries> found in <manifest>.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 32s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
here is the error, the main problem is each i install admob module #react-native-firebase/admob, it throws this error after trying a lot i couldnt find any solution, it only happens after installing admob module except that it build well, anyone knows whats wrong with that module
I was with the same problem and it work for me
in android/app/build.gradle
defaultConfig {
...
multiDexEnabled true // added for admob problem
}
...
dependencies {
...
implementation "androidx.multidex:multidex:2.0.1" // fix firebaseAdmob
}
in android/build.gradle
dependencies {
classpath('com.android.tools.build:gradle:4.1.2')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.3.3'
}
now open the android folder in Android Studio and wait for gradle will update
when finish the gradle update run npx react-native run-android
downgrade all the rnfirebase libraries that you are using to less than 10.0.0 (admob 7.6.11 and app 9.0.0), as I show in the image

How to know which version of Google Firebase plugin to use in Flutter app?

I've been stuck with Gradle not building (working on iOS fine). I struggled because Gradle was giving a generic error, finally got this today:
FAILURE: Build failed with an exception.
* What went wrong: Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[18.0. 0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.firebase:firebase-messaging:18.0.0 -> com.google.firebase:firebase-iid#[18.0.0], but fire base-iid version was 17.1.2.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact with the issue. -- Project 'app' depends on project 'firebase_messaging' which depends onto com.google.firebase:firebase-messaging#18.0. 0
-- Project 'app' depends on project 'firebase_core' which depends onto com.google.firebase:firebase-core#16.0.9 -- Project 'app' depends on project 'firebase_analytics' which depends onto com.google.firebase:firebase-analytics#16.5. 0 -- Project 'app' depends on project 'firebase_remote_config' which depends onto com.google.firebase:firebase-config#16.4 .1 -- Project 'app' depends onto com.google.firebase:firebase-core#16.0.9
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https:// github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b uild.gradle file.
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
This was after I took out the version numbers from my pubspec to see if that would help. I don't understand Google's version numbering and I'm not sure which versions of plugins I should be installing as it has caused conflicts in the past:
dependencies:
flutter:
sdk: flutter
http:
cached_network_image:
flutter_cache_manager:
carousel_pro:
cloud_firestore:
firebase_core:
firebase_remote_config:
dynamic_theme:
flutter_signin_button:
shared_preferences:
share:
flutter_search_bar:
google_sign_in:
#flutter_facebook_login:
flutter_html:
requests:
webview_flutter:
flutter_webview_plugin:
firebase_analytics:
flutter_app_badger: #for launcher badge icon (notifications)
uuid:
font_awesome_flutter:
device_info:
carousel_slider:
flutter_spinkit:
flutter_typeahead:
firebase_messaging:
html_unescape:
flutter_masked_text:
configurable_expansion_tile:
stripe_payment:
square_in_app_payments:
Google doesn't seem to maintain consistent version numbering and by taking out the version numbers I thought it would at least take the latest version of the plugins which theoretically should work. So, how can I solve this?
You should begin by putting the version number back in there.
This is an issue with firebase / play services versions being mismatched so you know for sure the other plugins in your pubspec.yaml are fine.
The dependancy which is failing is firebase messaging.
It's using many words to tell you
com.google.firebase:firebase-messaging:18.0.0 package depends on com.google.firebase:firebase-iid#[18.0.0]
but it's only finding 17.1.2.
You need
com.google.firebase:firebase-core#16.0.9
com.google.firebase:firebase-analytics#16.5.0
com.google.firebase:firebase-config#16.4.1
in the future, if you are having version issues check the specific packages GitHub issues to see if there's anything currently wrong with the version you're on. This will save you a lot of time.
I wouldn't recommend removing version numbers from your pubsepc.yaml but if you type
firebase_messaging: any
It will get a compatible version for you.
The error you are getting is not necessarily from the packages you have listed in pubspec.yaml. It is referring to the dependencies on build.gradle.
Google has no issue with the version numbers. There is a difference between the versions of packages i.e what you have listed on pubspec.yaml and the dependencies on app/build.gradle. It would be wise to reconsider the number of packages you use as every package has a dependency and you may end up in a sticky situation where multiple packages are conflicting. In addition you end up with a bloated solution for minimal functionality.
Removing version numbers will not help as some packages are incompatible. I would suggest you start with the packages you require i.e the firebase which from experience have no issues then incrementally add if necessary.

Flutter Firebase (firebase_core) does not build on Android

When using the Firebase plugins and starting an Android build, I get the following error:
ERROR: Failed to resolve: com.google.firebase:firebase-core:
Affected Modules: app, firebase_core.
It works fine on iOS.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.google.firebase:firebase-core:.
Required by:
project :app
project :app > project :firebase_core
This issue was fixed in the 0.3.4 update of firebase_core, which is a dependency of other Flutter Firebase plugins. You should be able to get the fix with a "flutter packages upgrade".
https://github.com/flutter/plugins/pull/1464/files
This is an issue that occurs because FlutterFire is migrating to BoM.
To solve this issue for now, you should just use firebase_core: 0.3.1+1.
The ideal solution would be adding the following to your settings.gradle in your android module:
enableFeaturePreview('IMPROVED_POM_SUPPORT')
However, this might not work. In that case, you should revert to 0.3.1+1 for the moment.
You can find out more about it here.

flutter version conflict with location and firebase_messaging

I am using two plugin with my flutter app location: ^1.4.1 and firebase_messaging: ^2.0.0
If I use single one its works fine but together
What went wrong:
Failed to capture snapshot of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
flutter clean
trying to downgrade version for both plugin
and google search
non of the above works for me.
app level build: implementation 'com.google.firebase:firebase-core:16.0.1'
project level build: classpath 'com.google.gms:google-services:4.0.1'
Thanks
:)
In your Project - Goto Android > App > build.gradle
Right after the apply plugin: 'com.google.gms.google-services' at the bottom of your build.gradle the following can be added to work around the issue.
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

Flutter: Build errors for cloud_firestore: above version "0.7.4"

I have been trying to resolve a build issue for hours until I realise it is due to Flutter plugin cloud_firestore. Version 0.7.4 builds fine for both Android and iOS but anything above 0.7.4 like 0.8.2+1 will have errors such as:
CloudFirestorePlugin.java:160: error: cannot find symbol
query = query.whereArrayContains(fieldName, value);
^ symbol: method whereArrayContains(String,Object) location: variable query of type
Query
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:598:
error: cannot find symbol
builder.setTimestampsInSnapshotsEnabled(
^ symbol: method setTimestampsInSnapshotsEnabled(Boolean) location: variable builder
of type Builder
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:678:
error: cannot find symbol
return FieldValue.arrayUnion(toArray(readValue(buffer)));
^ symbol: method arrayUnion(Object[]) location: class FieldValue
/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java:680:
error: cannot find symbol
return FieldValue.arrayRemove(toArray(readValue(buffer)));
^ symbol: method arrayRemove(Object[]) location: class FieldValue Note:
/Users/peterlumdev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+1/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. 4 errors FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org BUILD FAILED in 11s Gradle task assembleDebug failed with exit code 1
I would like to use 0.8.2+1 cloud_firestore for both ios and Android because of the support of
await db.settings(timestampsInSnapshotsEnabled: true);
Appreciate some help here. Many Thanks!
There is a problem with google-services.json.
In my case, I was in the same situation while coding Firebase for Flutter on Google Codelabs. I put GoogleService-Info.plist in Xcode in the corresponding folder and put google-services.json in the corresponding folder in Adndroid Studio as well. iOS Simulator worked, but in Android Studio the window like the one below is displayed, then pressing the OK button and launching Android Emulator resulted in the corresponding error.
When coding from scratch and inserting the google-services.json file from the Finder instead of Android Studio, no error occurred.
It's not working because it is creating a gradle conflict. Version 0.7.3 of firestore is working because gradle tooling is updated at that version. Please refer changelog and also refer this answer for any other working versions of firebase products.
I feel you, I've also spent hours and hours trying to figure this out.
After building a SSCCE, and then applying the settings of that project to my project, and then some tweaking, I got my project working.
Although I adjusted more settings than I care to remember, these seem to have had the highest impact:
In pubspec.yaml:
# included two other common libraries others might use
cloud_firestore: 0.8.2+1
firebase_auth: 0.7.0
google_sign_in: 3.2.4
Explicitly disable these two features in android/gradle.properties :
android.useAndroidX=false
android.enableJetifier=false
Use these versions of dependencies in android/build.grade:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
And finally, use these settings in android/app/build.gradle:
android {
compileSdkVersion 27
...
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
...
}
...
}
...
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:multidex:1.0.3'
}
It's also worth noting that I downloaded the google-services.json file again (though that didn't have any effect just by itself).
Any combination of these settings might help you.

Resources