I got the following error when trying to run a cloud function::
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error: Missing expected firebase config value databaseURL, config is actually{"projectId":"mynotes-b58d2","storageBucket":"mynotes-b58d2.appspot.com","locationId":"us-east4"}
If you are unit testing, please set process.env.FIREBASE_CONFIG
I was told I need to add the following::
"databaseURL":"https://xxxxx.firebaseio.com"
but I dont know where to add it, or what my baseURL is or where to find it
any help is welcomed
update::
i found where to add the info
firebase_options.dart>DefaultFirebaseOptions.
now i need to kmwo what my base url should be
update. i think i got it but i wanna tripple check with somone
I added in two places::
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'XXXX,
appId: 'AAAA',
messagingSenderId: '333333',
projectId: 'mynotes-flutter-project',
storageBucket: 'mynotes-flutter-project.appspot.com',
databaseURL: "https://mynotes-b58d2-default-rtdb.firebaseio.com/",
);
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'XXXX,
appId: 'AAAA',
messagingSenderId: '333333',
projectId: 'mynotes-flutter-project',
storageBucket: 'mynotes-flutter-project.appspot.com',
iosClientId:
'877208178211-pkk6a4dfdsmh1tfm4ffhdss9lmmjl0mc.apps.googleusercontent.com',
iosBundleId: 'se.pixolity.mynotes',
databaseURL: "https://mynotes-b58d2-default-rtdb.firebaseio.com/",
);
is this correct?
update: its not working :(
I recommend letting the flutterfire CLI generate firebase_options.dart for you, instead of trying to update it manually.
If the file doesn't contain a database URL, that's because you hadn't initialized the database in the Firebase console when you can flutterfire. After creating the database in the console, run flutterfire again to update the firebase_options.dart.
Related
Hi guys first time here on stack overflow.
I am currently building an app using flutter with firebase as the backend.
My target platforms are Windows and android
The android app builds fine
The windows app throws :
ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception:
PlatformException(channel-error, Unable to establish connection on
channel., null, null)
this only happens when I use :
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
I have also tried :
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "myapi",
appId: "appid",
messagingSenderId: "senderid",
projectId: "projectid",
storageBucket: "buckedid",
databaseURL: 'databaseurl',
));
As stated this works fine on android but not windows
I have the latest dependencies for Firebase
I have tried flutter pub outdated and it returns no Firebase dependencies
I have tried flutter pub upgrade
I have tried flutter clear
Hey if you are using the the latest versions of firebase you'd want to follow through the newest way of initializing firebase with firebase CLI. See this https://firebase.flutter.dev/docs/cli starting off by activating firebase cli
have something like this
// Import the generated file
import 'firebase_options.dart'; //this provides the current platform options via the currentPlatform getter from the DefaultFirebaseOptions class
...
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "API KEY",//<<==
appId: "ID",//<<==
messagingSenderId: "IF ANY",//<<==
projectId: "Project ID",//<<==
),
...
When I try to launch my Flutter Web App with Firebase I get the following error in my terminal
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following FirebaseException was thrown building HomePage(dirty, dependencies: [MediaQuery]):
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
The relevant error-causing widget was:
HomePage HomePage:file:///C:/Flutter/pbwebapp/lib/main.dart:37:13
When the exception was thrown, this was the stack:
...
I found other people had problems with this error but in my case I have called Firebase.initializeApp() in my main.dart file and I have also imported firebase_core in my pubspec.yaml
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
name: "pbwebapp",
options: const FirebaseOptions(
apiKey: "...",
authDomain: "..",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "...",
measurementId: "...",
),
);
runApp(MyApp());
}
Does anyone had this problem with Firebase trying to launch a Flutter Web App?
Thanks in advance!
Use Flutter Fire Cli to add flutter firebase packages like auth, messaging etc,
It will automatically configure all the things for you.
https://firebase.google.com/docs/flutter/setup?platform=ios
Okay so somehow removing the name parameter in the Firebase.initializeApp() function worked for me. But I dont know why exactly
I have the following error trying to create a static website inspired by https://github.com/aws-samples/aws-cdk-examples/blob/master/typescript/static-site/static-site.ts
const certificateArn = new acm.DnsValidatedCertificate(
this,
"SiteCertificateR53",
{
domainName: props.siteDomain,
hostedZone: props.zone,
region: "us-east-1", // Cloudfront only checks this region for certificates.
}
).certificateArn;
new cdk.CfnOutput(this, "CertificateR53", {value: certificateArn});
Error:
Received response status [FAILED] from custom resource. Message returned: Resource is not in the state certificateValidated
If you don't need to do cross region stuff (e.g. us-east-1 needs a resource from us-west-2) using the following method provides the same benefit as DnsValidatedCertificate
const certificate = new acm.Certificate(this, `SiteCertificateR53`, {
domainName: props.siteDomain,
validation: acm.CertificateValidation.fromDns(props.zone)});
If you still gotta do cross-region stuff, then you should create and deploy your zone via AWS console first. That won't guarantee a fix though, this page can help if you're still stuck: https://docs.aws.amazon.com/acm/latest/userguide/troubleshooting-DNS-validation.html
I'm trying to seed the Firebase Storage Emulator. I've added a json file to my project and I'm trying to upload this file to the Storage Emulator during the seed phase:
await firebaseAdmin
.storage()
.bucket()
.upload(path.join('./data/cars.json'), {
destination: `vehicles/cars.json`,
});
Unfortunately this does not seem to work and I'm running into the following error:
TypeError: Cannot read property 'length' of undefined
The way I did this was by using firebase-tools
firebaseCli.emulators.start({
project: "project-id",
import: "path-to-file.json"
})
This will work only if the firebase emulator setup is done correctly and the data you are trying to import has the correct format.
For the Firebase Storage Emulator to work you need to initialize it in the Admin SDK:
firebaseAdmin.initializeApp({
credential: firebaseAdmin.credential.cert('path/to/credential'),
storageBucket: "bucket-name",
});
I've finally got user signed up with this cloud function:
const functions = require('firebase-functions');
const {
dialogflow,
Image,
} = require('actions-on-google')
// Create an app instance
const app = dialogflow()
// Register handlers for Actions SDK intents
app.intent('test', conv => {
conv.ask(new SignIn());
})
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)
But right after that i'm getting the same error:
TypeError: Cannot read property 'client' of undefined
at Function.<anonymous> (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:120:71)
at next (native)
at /user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:22:71
at __awaiter (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:18:12)
at Function.handler (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:84:16)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/dist/assistant.js:55:32)
at next (native)
at /user_code/node_modules/actions-on-google/dist/assistant.js:22:71
at __awaiter (/user_code/node_modules/actions-on-google/dist/assistant.js:18:12)
at standard (/user_code/node_modules/actions-on-google/dist/assistant.js:51:41)
It doesn't even get to the console.log('test'):
const functions = require('firebase-functions');
const {dialogflow} = require('actions-on-google')
// Create an app instance
const app = dialogflow()
// Register handlers for Actions SDK intents
app.intent('test', conv => {
console.log('test')
conv.ask(`response`)
})
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app)
Package.json:
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "~6.0"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "2.1.3",
"firebase-admin": "5.12.1",
"firebase-functions": "1.0.3",
"dialogflow": "0.5.0",
"dialogflow-fulfillment": "0.4.0"
}
}
goto your action on google app Develop section, goto account linking, expand Google Sign In Client Information you will see Client ID issued by Google to your Actions copy that client id.
when initializing your app in
const app = dialogflow();
pass in an object with your actions on google account linking client id
your code should look like:
const app = dialogflow({
clientId : YOUR_APPS_CLIENT_ID
})
This will fix this issue.
To Get YOUR_APPS_CLIENT_ID, go to actions on google console, on the left nav menu, under advanced options, go to account linking and expand the third card to get your id.
Hope it helps.
Update for September 2019
If you can't find your Client ID (as it was for me, because it seems Google doesn't show it anymore within the "Google Sign In Client Information" card), then go to your Google Cloud Platform console and under APIs and Services menu, open the Credentials screen.
Then scroll to the OAuth 2.0 client IDs section and find "New Actions on Google App". The value in the last column is your Client ID for Actions on Google project.
Here is the screenshot:
I faced this issue when I didnt want to accountlink in a test project of mine, I had left accountlinking on from when I was testing something. When I connected a webhook without any clientID in the code I got the error. All I had to do was clear the accountlink settings from the Google project and then everything was solved.