Firebase auth/argument-error when building NextJS through github actions - firebase

I'm building a NextJS website which functions with the static HTML export. I have setup a github action which builds and exports the project with yarn. This action works perfectly locally, however on Github I get the following error:
Error [FirebaseError]: Firebase: Error (auth/argument-error).
{
type: 'FirebaseError',
code: 'auth/argument-error',
customData: { appName: '[DEFAULT]' }
}
I debugged the entire Firebase connection I have written but everything seems according to the Firebase docs. What is happening?

Related

Expo-notifications A valid firebase project ID is required to communicate with Firebase server APIs

I have a react-native application with its backend in NodeJS. I started implementing notifications using expo-notifications and it is working fine in production with iOS but not with Android.
I have followed this documentation to implement everything. I know that for android I have to setup FCM which is what I did using this.
What I did :
Created my Firebase App
Added Firebase to my Android App
My Android package name is the same as the value of android.package in my app.json
Downloaded google-services.json and placed it in my Expo app's root directory
Uploaded the server credentials using expo push:android:upload --api-key . This has been well configured because when I do expo push:android:show I see the correct token
However, in production I get this error:
Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager. Please set your Project ID. A valid firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Goolge.
Did I forget any of the steps ? What is wrong with my project ID? Do I need to completely rebuild my code and send it on Google Play Store or can I do an instant update using expo publish ?
Here is my app.json android in case:
"android": {
"versionCode": 13,
"userInterfaceStyle": "light",
"package": "com.xxx.xx",
"googleServicesFile": "./google-services.json",
"useNextNotificationsApi": true,
"permissions": [
"CAMERA",
"CAMERA_ROLL",
"MEDIA_LIBRARY",
"WRITE_EXTERNAL_STORAGE",
"READ_EXTERNAL_STORAGE",
"NOTIFICATIONS"
]
},
Any help would be appreciated :)
PS : I had a look at this question but still getting same problem.

Build Next.js app before deploying via Serverless Component

We're using the Next.js Serverless Component from: https://serverless-nextjs.com/ to deploy our Next.js app to AWS using the Serverless framework.
It takes around 7-8 mins for the app to be built and then deployed to AWS.
We were hoping to instead build the app up-front and then deploy the pre-built code...
You can tell Serverless to not build and just do the deployment with build.enabled: false:
# serverless.yml
myNextApplication:
component: "#sls-next/serverless-component#3.7.0"
inputs:
bucketName: our-bucket-name
build:
enabled: false
However when we run yarn next build the app is built under ./next.
When serverless builds the app it stores the state in .stateless and the files in .stateless_nextjs. So therefore the next build isn't compatible with deploying a prebuilt app...
This means if we try and build the app and then call serverless after we get the following error:
myNextApplication › Error: ENOENT: no such file or directory, open '/Users/cameron/Projects/nextjs-serverless/.serverless_nextjs/default-lambda/manifest.json'
So how do you build the app first and then deploy the build using Next.js Serverless Component?
Versions:
"dependencies": {
"next": "12.2.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"serverless": "2.72.2"
},
component: "#sls-next/serverless-component#3.7.0"
The reason is probably wrong next.js middleware setup. manifest.json is built upon simulated requests that goes through nextjs middlewares. please refer to this stackoverflow answer.
nextjs middleware had some structural changes around v12.x that requires migration. it's hard to figure out what's wrong because it gives little or no warning messages and it builds okay. I had similar issues too.
Solution
check if your deploy includes proper package lock file(yarn.lock, package-lock.json...) so that fixed version of next.js is included when deploying.
check latest middleware examples from github repo and try match middleware file structure and code.
check out nextjs middleware migration guide mentioned earlier; try build in local environment and make sure manifest.json is created.

firestore is not working with React Native Expo

I installed firebase with react native expo using expo add firebase, then
I created a file (firebase.tsx) and added the Firebase configuration and initialized the app like in this screenshot with correct values].
I have added the google-services.json and
GoogleService-info.plist to the root of my expo project like the documentation say and i am importing firebase in my api service like this import Firebase from './../../../firebase'.
In my register function I call the firebase create user function
const response = await Firebase.auth().createUserWithEmailAndPassword(values.email.value, values.password.value)
The response is never returned, and if I use . then nothing happens either.
If I log firebase.auth I get an object with my API key and app name, etc. so Firebase is installed, but whenever I call the database for sign in or to access a collection nothing happens.
This is my package.json.
This is my app.json.
I added bundleIdentifier and googleServicesFile to iOS and package and googleServicesFile for Android.
currently Firebase seems not to be working in expo if you are using the android configuration. I have tried the web configuration and it has worked for me. Here is the youtube tutorial for it. Watch from 38:20 to set up.

Unity Firebase Crashlytics not sending any crash reports, getting "failed to retrieve settings" error on logcat

Unity editor version: 2019.3.15f1
Firebase Unity SDK version: firebase_unity_sdk_6.15.2
Additional SDKs im using: Unity IAP, Gamesparks, Ironsource, Facebook, Appsflyer, GameAnalytics
Platform im using the Unity editor on: Windows
Platform im targeting: Android
Scripting Runtime: IL2CPP
Problem
I am getting data on firebase analytics, but I cannot get crashlytics to report anything. Im stuck on this...
Steps to reproduce:
Add the firebase analytics and crashlytics sdks.
Add the google-services.json GoogleService-Info.plist files somewhere in assets folder
Add this code to initialise the firebase
// Use this for initialization
void Start ()
{
// Initialize Firebase
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
// Crashlytics will use the DefaultInstance, as well;
// this ensures that Crashlytics is initialized.
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
// Set a flag here for indicating that your project is ready to use Firebase.
VisualDebugger.SetText("crashlytics initialised");
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}",dependencyStatus));
VisualDebugger.SetText("crashlytics NOT initialised: " + dependencyStatus);
// Firebase Unity SDK is not safe to use here.
}
});
Invoke("IsCrashEnabled", 5f);
}
void IsCrashEnabled()
{
VisualDebugger.AddLine("IsCrashlyticsCollectionEnabled: "+Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled);
}
In order to get the app to run with the facebook sdk installed Ive added these two lines to proguard-user.txt
-keep public class com.facebook.**{public *; }
-keep public class com.facebook.internal.**{ public *; }
and commented out the following lines from mainTemplate.gradle
//implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
When I run the app, firebase is initialised successfully. Also Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled returns true.
I crash the app in a number of different ways, then open it again without reinstalling. But no crash reports are sent.
When I watch logcat when starting the app I see this error from firebase each time the app is opened
2020-09-28 16:18:59.332 25773-25847/? E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/REDACTEDblahblahblah/settings
Update Oct 19, 2020:
Today a developer updated the issue I linked in this answer saying the Firebase team fixed a backend bug last Friday (Oct 16) that was affecting some new Unity Android apps registering w/ Firebase - likely the bug behind your issue. I had already solved the issue in my own project using the below solution, but if you haven't yet updated your project, I recommend running it again and seeing if Crashlytics is working for you now..
I've been dealing with the same issue this week in Unity 2019.4.11f1 - i see the same error message about not being able to retrieve settings, but with my specific project and appIds in the URL.
I found a solution in this Github issue, which suggests the problem is caused by the version of an android library that is a dependency for the Unity Firebase Crashlytics package. My rough understanding is that the firebase-crashlytics-unity library is a wrapper around android library firebase:firebase-crashlytics, and the unity package allows the underlying native Android code to be used from Unity. Version com.google.firebase:firebase-crashlytics:17.10.0 has issues with getting the settings for some Firebase projects on Android. Myself and several others following this issue found forcing Unity to use this specific dependency at version 17.1.1 resolved the issue.
Someone else with the same issue in the thread contacted Firebase support and was told:
The error you are seeing "Failed to retrieve settings" is related to
the SDK version being used. If you go to "Assets > Firebase > Editor>
CrashlyticsDependencies" you can manually update the SDK to point to
the latest Crashlytics SDK version 17.2.2. Please give it a try and if
you continue having issues, let me know.
It turned out this advice wasn't quite right - some of us following the thread then experienced a different issue when using the Android Crashlytics SDK version 17.2.2 with Unity crashlytics version 6.16.0. So I'd specifically recommend trying out the below suggestion or other solutions in the thread to set your Android crashlytics library to v17.1.1.
Changes I made in my project to address this:
First, I updated my unity firebase packages in the package manager to use version 6.16.0. In my project 4 packages were installed - core, analytics, crashlytics, and messaging.
Then I searched for the the Crashlytics package's dependency file - Crashlytics-Dependencies.xml (found by searching project - was in /Library/PackageCache/com.google.firebase.crashlytics#6.16.0/Firebase/Editor/ for me). This file initally had "com.google.firebase:firebase-crashlytics:17.0.0" listed, which I updated to be: "com.google.firebase:firebase-crashlytics:17.1.1".
As an extra precaution, I also added created a MyProject-Dependencies.xml file, as was suggested by a user in the thread - this file also specifies version "com.google.firebase:firebase-crashlytics:17.1.1".
Next, I modified the Unity build process to use a custom mainTemplate.gradle file to specify dependencies,
rather than using the External Dependency Resolver to manage and
embed unity packages (option in Build Settings > PlayerSettings >
Android).
I also updated the settings on the External Dependency Manager Android Ressolver:
Disabled AutoResolve and Disabled Resolve on Build (we dont want EDM updating dependencies without our knowledge when building)
I also turned disabled AndroidPackageInstallationEnabled - this has made the resolution process much faster and removed a bunch of .aar files from the android dependencies list, and hasn't caused any problems in my project.
I then ran External Dependency Resolver > Android > Force Resolve, which after the settings changes above, should now embed a list of the dependencies for the Android build into the mainTemplate.gradle file - Check this file (its in Assets/Plugins/Android) and you should now see com.google.firebase:firebase-crashlytics:17.1.1 in that list.
Also, I recommend reading this article about managing Unity Firebase dependencies from one of the Firebase developer advocates, Patrick Martin. It helped me wrap my head around how Android dependency management in Unity works, as well as how the Android gradle build process works.

React Native error logging with firebase Crashlytics - How to get javascript stack trace

I have a React native application with configured using react native firebase lib and added the module of Crashlytics.
Everything works okay but when i try to log an error using recordError() method or when i just use crash() its just logs errors in the dashboard in native form. I tried to find a way of getting js error to the dashboard but so far nothing has worked.
Is this possible or i should try a different way?
maybe another platform like
bugsnag or sentry?
This is working for me and showing javascript stacktrace:
....
catch (error) {
crashlytics().recordError(new Error(error));
}
you can use react-native-exception-handler to get a js stack trace for the crash and also send js stack trace to firebase crashlytics
like this
import {getJSExceptionHandler} from 'react-native-exception-handler';
setJSExceptionHandler((error, isFatal) => {
if(isFatal)
{
crashlytics().recordError(new Error(error));
}
});

Resources