'No matching client found' with Flavors in Flutter - firebase

I want to use Flavors for dev and prod, and connect each to a firebase project. I've done the proper setup, but keep getting this error:
Execution failed for task ':app:processDevDebugGoogleServices'. No matching client found for package name 'applicationid.dev'
my build.gradle:
flavorDimensions "app"
productFlavors {
dev {
dimension "app"
resValue "string", "app_name", "App Dev"
applicationIdSuffix ".dev"
}
prod {
dimension "app"
applicationId "applicationid"
The project exists in firebase, the names match, and I've added google-services.json to the proper folder (app/src/dev/google-services.json)
Any idea why this is happening? Thanks in advance!
EDIT
I also tried adding an app inside my main (prod) firebase project, and generating only one google-services.json to manage both. I ran the app as -dev and it ran, but still connected to prod database.
EDIT 2
For people running into the same problem, I got it working by deleting google-services.json from app/ root. Leave the google-services files only inside their proper folders in app/src/...

Related

Firebase CLI suddenly ignoring environment variables on Functions deployment

I have a Firebase code project with Functions meant to be deployed to multiple Firebase projects over multiple regions.
I used to set the deployment region like this:
return functions
.region(process.env.REGION)
// ...
and used this command to deploy:
$ REGION=us-central1 firebase deploy --only functions
it worked like a charm until recently. Now it seems to completely ignore REGION=us-central1 even if I export it before I run firebase deploy.
EDIT 2022-06-13 - Possible solution
I changed the code to dump the contents of process.env to a file during deployment. This is what I got:
{
"FIREBASE_CONFIG": "{\"projectId\":\"REDACTED\",\"storageBucket\":\"REDACTED.appspot.com\",\"locationId\":\"us-central\"}",
"GCLOUD_PROJECT": "REDACTED",
"CLOUD_RUNTIME_CONFIG": "{REDACTED}",
"__CF_USER_TEXT_ENCODING": "REDACTED"
}
so definitely is not the same list of variables I have in my local environment.
I could use the locationId from FIREBASE_CONFIG to get the target location, or CLOUD_RUNTIME_CONFIG (it contains the dump of the functions .config() object, so I could set the target there).
I also believe that I could use the .env and .env.{project alias or ID} files and their contents would be available in process.env at deployment time.
As per Osvaldo López's suggestion, here are some other details:
Running on MacOS
No errors are reported
No recent changes to the CLI
Any input would be very welcome! Thanks.

HTTP Error: 403, Permission iam.serviceAccounts.create is required to perform this operation on project "X" FIREBASE

I created a project in firebase, then I made them commands:
firebase login
firebase init
I associated it with my Github and finally
firebase deploy
from project "X" and it worked normally, then, I deleted project y from Github and Firebase and when I try to deploy from a new or different project I get the following error:
HTTP Error: 403, Permission iam.serviceAccounts.create is required to perform this operation on project "X"
You can see the error here:
As you can see in the output, there is a default project in your .firebaserc file located in the directory you choose to initialize the project.
The first thing you need to do is delete the Secret in Github that you share with Firebase in your previous deploy.
For doing that go to your Github Project:
your-project > Settings > Secrets > FIREBASE_SERVICE_ACCOUNT_PROJECT_ID
And remove it.
Then open the file .firebaserc and be sure that the default project is pointing to your current project ID:
{
"projects": {
"default": "id_of_previous_project"
},
After editing property:
{
"projects": {
"default": "id_of_current_project"
},
Then run the script again to get the initial configuration. If the error persist when you deploying or during the initialization, you should run the following command in order to change de default project that Firebase Cli uses in a directory:
firebase use --add

Auth0 and Next.js deployed to Vercel: Location header error

I started with this sample repo: https://github.com/vercel/next.js/tree/canary/examples/auth0
My current repo: https://github.com/rebeccapeltz/next-auth-app-1
Login/Logout work fine locally. When I deploy to Vercel and logout I get this message in the browser:
Invalid character in header content ["Location"]
I've double checked the Auth0 env variables and they seem correct. Login works fine on Vercel. Can't figure out how to troubleshoot the header Location value that is causing the problem.
Nothing much going on yet and easy to reproduce: https://next-auth-app-1.now.sh/
Solved this by removing all env variables added to the Vercel online application settings. Then added the secrets using the now CLI now secrets add and deployed the app by setting up other env variables in now.json and using now --prod. Working OK now. For further external env secrets and references, I'm wondering if t's better to add them via now.json or to use the online settings GUI. One thing that wasn't clear is that when you add variables with now add secrets you need to prefix the value in the now.json with #. Kind of like accessing bash env variables with $. So after adding secrets my now.json looks like this
{
"build": {
"env": {
"AUTH0_DOMAIN": "<name of auth0 domain>",
"AUTH0_CLIENT_ID": "<what you get from auth0>",
"AUTH0_CLIENT_SECRET": "#auth0_client_secret",
"REDIRECT_URI": "<name of vercel app or domain name>/api/callback",
"POST_LOGOUT_REDIRECT_URI": "<name of vercel app>/",
"SESSION_COOKIE_SECRET": "#session_cookie_secret"
}
}
}
Should you add all env using secrets add and then just reference by name in the now.json? not sure.

Unity/Firebase - Project Bundle ID does not match any bundle IDs in your google-services.json files

I'm making a mobile game on Unity, Android first.
And now I'm integrating firebase analytics.
After set info on Firebase Console and put google-services.json file into Unity project, Unity shows an error saying :
Project Bundle ID com.RetroSpirit.ToiletRush does not match any bundle IDs in your google-services.json files
This will result in an app that will fail to initialize.
Available Bundle IDs:
You need to either:
* Fix your app's bundle ID under "Player Settings --> Bundle Identifier"
or:
* Add another app to your firebase project
Goto https://firebase.google.com/docs/unity/setup#add_firebase_to_your_app_1
and add the new configuration file to your project.
UnityEngine.Debug:LogError(Object)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:LogErrorIfEnabled(String)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:FindGoogleServicesFile(SortedDictionary`2, String, LogMessage, LogMessage)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:FindGoogleServicesFile(String, LogMessage, LogMessage)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:UpdateJson(Boolean, LogMessage, LogMessage)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:OnPostprocessAllAssets(String[], String[], String[], String[])
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Here's the part of google-services.json,
"client": [
{
"client_info": {
"mobilesdk_app_id": "*:***********:android:****************",
"android_client_info": {
"package_name": "com.RetroSpirit.ToiletRush"
}
},
"oauth_client": [
{
"client_id": "***********-********************************.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.RetroSpirit.ToiletRush",
"certificate_hash": "****************************************"
}
I don't know what should I check.
Project Bundle ID (the Package name on Build Settings - Other Settings - Identification) is exactly same as package_names in google-services.json.
Any ideas?
My case was in Unity and to fix it I added the google-services.json from the firebase project to the assets folder. I had only the GoogleService-Info.plist before.
Little bit funny to answer myself...
I found the reason of problem accidently. There was something wrong with my VC runtime so generate_xml_from_google_services_json.exe couldn't extract package name from google-services.json. (vc90.crt.manifest could not be extracted!)
Unfortunately, I couldn't fix that runtime error despite so many re-install of Visual Studio, VC Runtime and .net frameworks. Finally I re-installed Windows 10 and the problem just gone away... Still don't know what caused this error.
I understand you have fixed this by re-installing Windows but this is how I got passed this problem in case anyone else runs into this:
Make sure you have set your Package Name in Unity player settings (Edit > Project Settings > Player > Other Settings > Identification > Package Name).
Set to the same one you set up in Firebase (looks like com.CompanyName.ProductName).
Make sure you have imported the Firebase assets into your Unity project as described here https://firebase.google.com/docs/unity/setup and that the Firebase folder exists in Assets > Firebase. Changing the location of this folder seems to break things.
In our case we solved the issue by requesting a new google-services.json file from a collegue who has admin rights.
In my case, the issue was with the Package Name. So I followed the following steps and solved the problem:
Change the package name (com.companyname.appname) [everything in lowercase]
Delete the existing keystore
Add a new keystore and generating a fingerprint with Keytool
Delete the current app from the Firebase console
Add a new app with the correct package name and the generated fingerprint
download google-services.json again and Import to Unity under the Assets folder
Done! It works!!
hey everyone I found a fix to this issue I'm using mac pro m1
step to fix
reinstall visual studio
download Microsoft.NET.Sdk.Android from the visual studio website
restart the project
and after that, it will fix

Firebase Serve Error

I am new to firebase and am trying to make a simple app that utilizes user authentication. At this point in the project I am trying to run firebase on a local server using CLI commands.
I have set up firebase init and firebase deploy. When I type firebase serve on my project folder i get the response,
"an unexpected error has occurred".
Below i am attaching the contents of my firebase-debug.log file. Any help would be appreciated. Thanks
command requires scopes:
["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase",...
[debug] [2017-06-11T17:09:09.607Z] > authorizing via signed-in user
TypeError: Cannot read property 'public' of undefined
Look in your firebase.json file, which you should have in the directory where you're running firebase serve. It should look something like this:
{
"hosting": {
"public": "app",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
If it doesn't have that "hosting" key, then you'll get that Cannot read property 'public' of undefined error because firebase serve tries to access .hosting.public.
I faced this issue today, I ran it with --debug and found out that I've installed npm/node as sudo user, running following:
firebase serve
was giving me this error:
Error: An unexpected error has occurred.
When I ran it with sudo, I was able to deploy hosting and functions locally:
sudo firebase serve --debug --only hosting,functions
1) create a folder called "public" and put your files inside.
2) edit the firebase.json and just write this:
{
"hosting": {
"public": "public"
}
}
This appears to be a bug - that ideally should be resolved with Firebase Init. I have logged a support ticket with Firebase, and would encourage others to do so as well.
I think you may have skipped an initialization step by accident (I did the same thing on my first run-through)
Try this (from your same project directory):
1) firebase init
2) When prompted for which services you'll need make sure that Database AND Hosting options have their markers highlighted green (tab to Hosting with the spacebar). It's easy to select just database and let it run its configuration and assume it configures all of the bulleted options below it if you do not watch closely because the stdout info isn't very clear. Now hit Enter
3) Accept the default database settings as you probably did before, and when asked "What do you want to use as your public directory? (public)", hit Enter.
At this point you should be good to go spin up a local firebase web server...
4) try 'firebase serve', hit Enter, and you should get a verification that hosting files are being served from /public
Hope this helps. Good luck.
As for me the error is (--debug attr)
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/#google-cloud/functions-emulator/logs'
So the solution will be to run with sudo

Resources