Firebase Invalid API key
Asked Answered
H

4

6

I have an android project which I want to expand with Firebase. Currently I've got an error logging when I want to test a crash with a log message.

Server did not receive report: Origin Error message: API key not valid. Please pass a valid API key.

What can I do to fix this? I've copied the google-services.json file to my project from the console.

Hormonal answered 6/4, 2017 at 9:37 Comment(2)
check package name correctlyOglethorpe
@Oglethorpe I've used the Firebase Tool in AS, synced etc.. I'm working with multiple build flavors but the package names are correct in the config files.Hormonal
B
5

Got the same error in my Angular project. I know the question is for android but this is the question that pops up when I searched the error for angular so hopefully, it would help another person in the near future. Make sure you're importing the right variable. In the app.module.ts file:

import { FIREBASE } from 'src/environments/firebase';

imports: [
    AngularFireModule.initializeApp(FIREBASE.firebase)
  ],

firebase.ts (environment file) fill with your config info from firebase.

export const FIREBASE = {
  production: false,
  firebase: {
    apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: ""
  }
};

So make sure you're importing the right variable. Took me some time to figure out. Happy coding!

Berndt answered 20/6, 2020 at 4:25 Comment(0)
T
4

Make sure you've got the API keys set correctly in your Google Developer Console for your Firebase project.

Totality answered 6/4, 2017 at 10:11 Comment(1)
I'm using the key which is created for me with the name "Android key (auto created by Google Service)"Hormonal
F
0

There are two different configurations for release mode and test mode. make sure that you use the API key which is related to each. In the angular there are two environment files. environment.prod.ts which is for production and environment.ts which is for testing. make sure that the api key in these files are correct.

Fulfill answered 26/3, 2021 at 14:58 Comment(0)
W
-8

good night, I solved this problem with


    npm i firebase --save

Wheen answered 16/7, 2019 at 3:15 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.