ionic cordova fcm notifications error with firebase - firebase

i want to implement the notifications feature by firebase on my ionic application
so after proceeding with the following command
ionic cordova plugin add cordova-plugin-fcm
and adding the google-services.json to the main folder of my ionic project I am facing the following error with no success to solve it
(node:15256) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): TypeError: Invalid data, chunk must be a string or
buffer, not object
(node:15256) [DEP0018] DeprecationWarning: Unhandled promise rejections are
deprecated. In the future, promise rejections that are not handled will
terminate the Node.js process with a non-zero exit code.
i found on google that firebase has several bugs on it's latest version which is 4.8.2 and 4.8.1 so as well i did a downgrade to firebase 4.8.0.
as well i tried the npm install and npm cache verify and i checked that i have the same package name in my project and firebase with no success to solve it.

Related

Flutter:The plugin firebase_auth could not be built due to the issue above

I just use firebase_auth package to send me code by phone Number. it work fine in debug mode but when I try to get apk it show me this error. can anyone help me please?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sms:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\Mohammad Asef\.gradle\caches\transforms-2\files-2.1\8014592fef965c457f4d96ed4583a915\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\Mohammad Asef\.gradle\caches\transforms-2\files-2.1\8014592fef965c457f4d96ed4583a915\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 3m 52s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 233.5s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the
incompatibility.
Building plugin firebase_auth...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 0.3s
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
The plugin firebase_auth could not be built due to the issue above.
firebase_auth is using AndroidX libraries, but your flutter project is still using the old android support library. To solve this upgrade to flutter latest version. From the docs:
How do I know if my project is using AndroidX?
Starting from Flutter v1.12.13, new projects created with flutter create -t <project-type> use AndroidX by default.
Projects created prior to this Flutter version must not depend on any old build artifact or old Support Library class.
In an app or module project, the file android/gradle.properties or .android/gradle.properties must contain:
android.useAndroidX=true
android.enableJetifier=true
https://flutter.dev/docs/development/androidx-migration
I solved it by adding firebase_analytics dependency in pubspec, then adding manually string value of default_notification_channel_id in android resource just like below
<string name="default_notification_channel_id" translatable="false">fcm_default_channel</string>

Flutter Cloud Firestore compile error: CloudFirestorePlugin.java uses unchecked or unsafe operations

I am getting an error message when I run my app with the cloud_firestore: 0.13.7 plugin. But it still builds the app. How do I get rid of this error?
This is a warning, in your build.gradle file change the minSdkVersion to version 21 and run the app again.

Can't integrate Firebase with my application

When I integrate Firebase with my app, Build failed with an exception.
Although the first error that occurred was a gradle update, i've tried and i still get an error while running gradle.
Because there was no error in the code and the amount of coding was too much, I can only show error messages.
Error running Gradle:
ProcessException: Process "C:\Users\82109\AndroidStudioProjects\instargram_clon\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
Configure project :app
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
*********************************************************
WARNING: This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX.
See goo.gl/CP92wY for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
Command: C:\Users\82109\AndroidStudioProjects\instargram_clon\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
※ When integrating Firebase with my app, I'm wondering if several versions are all up-to-date. This is because i have optionally and randomly changed to the latest version.
for firebase you can integrate your app manually see firebase documentation
for a quick answer follow this steps:android
Create a Firebase project
Register your app with Firebase
Add a Firebase configuration file (google-services.json)
Add Firebase SDKs to your app
WARNING: This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX => update your image_picker

You attempted to use a firebase module that's not installed on your Android project by calling firebase.config()

i am getting the following error in android after adding notifications to the app.
Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.config().
Ensure you have:
1) Installed the required Firebase Android SDK dependency 'com.google.firebase:firebase-config' in your 'android/app/build.gradle' file.
2) Imported the 'io.invertase.firebase.config.RNFirebaseRemoteConfigPackage' module in your 'MainApplication.java' file.
3) Added the 'new RNFirebaseRemoteConfigPackage()' line inside of the RN 'getPackages()' method list.
when i do all the recommended things (com.google.firebase:firebase-notifications:16.0.0) i am getting
that the firebase-notifications:16.0.0 is not found error while running

firebase serve: supervisorPort (5001) is already in use

I built this React App, that allows users to add todo item, and mark an item as completed/active. Todo items are stored in cloud firestore.
I want to enable full-text search on the app, and one way is to create a cloud function that writes index to Algolia whenever cloud firestore witnesses a create operation.
Inside my app root directory, I initialize cloud functions and then implement the onTodoAdded function. After done, I run firebase serve under functions directory and get the errors:
=== Serving from '/Users/evan/source/react-redux-todos'...
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.6.0 but Google Cloud Functions only supports v6.11.5.
i hosting: Serving hosting files from: build
✔ hosting: Local server: http://localhost:5000
error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
at Server.setupListenHandle [as _listen2] (net.js:1335:14)
at listenInCluster (net.js:1383:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1509:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
error: supervisorPort (5001) is already in use
i functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
For a complete debug log, find here.
However, this command works fine: firebase serve --only functions.
=== Serving from '/Users/evan/source/react-redux-todos'...
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.6.0 but Google Cloud Functions only supports v6.11.5.
i functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
Since it says supervisorPort(5001) is already in use, I lsof -i:5001 and finds no process. I also shut down my laptop and restart, gets the same error.
I find the similar issue here, however didn't find the solution.
I still don't know the reason, but adding --port=9000 solves the problem. For example, firebase serve --only functions --port=9000. Credits to restPort (5001) is already in use #142.
I was having this same error after updating to macOS Mojave 10.14.1 (was fine with 10.14). error: supervisorPort (5001) is already in use and it led me down this rabbit hole of additional updates and configuration that eventually got it to work.
1 Update Node Packages
I updated these items to these versions (latest as of this writing)
firebase-functions: 2.1.0
firebase: 5.5.8
I deleted by node_modules folder and reinstalled all the packages.
2 Firestore Emulator Setup Required
Next time I attempted to serve, firebase gave me this error:
Setup required, please run: firebase setup:emulators:firestore
Because of the weird permissions issues I initially had with mac, I actually have to run
node_modules/.bin/firebase setup:emulators:firestore
3 Then.... Fix Java Runtime Issues
On my next serve attempt, I was presented with firestore: No Java runtime present, requesting install. Mac presents a popup leading to a page where you can "download java for mac". This isn't what you actually need. You really need the Java SE Development Kit which enables command line interface.
Then... You may get these errors the next time you try to serve.
error: restPort (5002) is already in use
error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1501:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
error: supervisorPort (5001) is already in use
But Firebase still ended up continuing to successfully serve somehow, despite these errors. And it still shows my app over http://localhost:5000.
Hope this helps!

Resources