Firebase - Changing file name google-services.json? - android

Can I change the file name google-services.json to prod-google-services.json?

You should not change the name of the file if you intend to use it. If you're going to use different google-services.json file depending on the app environment, you should Configure Product Flavors.
See Firebase 2.0 - how to deal with multiple flavors (environments) of an android app?

You cannot change the google service file name. You can use flavour to manage the google-services.json file.
Like this:
app/src/
flavor1/google-services.json
flavor2/google-services.json
Look here for detail.
Also, very important to note : You should not delete the google-services.json file from your app folder. Firebase will automatically use google-services.json file from flavor folder if it is present and neglect the google-services.json file from app folder. [Thanks #KrishnaAgarwal]

No you can not change file name . it was detected by android gradle while building project.

Related

Failed to read Firebase options from the app's resources

I get the error Failed to read Firebase options from the app's resources. Either make sure google-services.json is included in your build or specify options explicitly.
When building the unity game to android, even though it works in the editor.
I have tried all the solutions of previous questions. Notably, I don't have a mainTemplate.gradle file, and inside /Plugins/Android I don't have a firebase folder. I am using the .net framework, and I enabled arm64. I also have the googleservices.json both in the assets folder and streamingassets folder. Are there any other solutions? Thanks!
When you want to build to an android project, you need to have a keystore file and I didn't have one. Here is a link to explain how to create the keystore file:
https://github.com/firebase/quickstart-unity/tree/master/database/testapp

Is it possible to extract google-services.json from the apk file?

New to android development. When we distribute the .apk file, can the receiver extract the google-services.json and use our database or authentication database.
I looked
I have apk file, Is it possible to get android studio project from apk?
and Is google-services.json confidential?
and Is it possible to decompile an Android .apk file?
but don't directly relate
I tried to extract an apk of mine which has google-services.json file and I couldn't find the google-services.json file in extracted folder .
Edit : Here is more info I found
The google-services plugin has two main functions:
1 - Process the google-services.json file and produce Android resources that can be used in your application's code. See Adding the
JSON File more information.
2 - Add dependencies for basic libraries required for the services you have enabled. This step requires that the apply plugin:
'com.google.gms.google-services' line be at the bottom of your
app/build.gradle file so that no dependency collisions are introduced.
You can see the result of this step by running ./gradlew
:app:dependencies.
This means that the google-services.json file will be converted to android resources by google-services plugin during build process .
You can find how google-services.json works over here
can the receiver extract the google-services.json and use our database or authentication database.
Even if the receiver extracts credentials from apk , he cannot access database as the SHA-1 will be different .

Gradle build failing due to keystore.properties file missing

I'm trying to use this alarm app on Android Studio - https://github.com/philliphsu/ClockPlus . However, gradle build is failing (error message below). Please let me know what needs to be fixed for this to work.
Error:/Users/***/Documents/Apps/ClockPlus-master/keystore.properties (No such file or directory). Let me know what exactly is this keystore.properties and is it possible to create this file as it's not available in the github repo files.
what exactly is this keystore.properties?
When you want to publish your app in the google play, you need to sign your app. When you create a signing configuration,Android Studio ,by default, adds your signing information in plain text to the module's build.gradle files. If you are working with a team or open-sourcing your code, you should move this sensitive information out of the build files so it is not easily accessible to others. To do this, you should create a separate properties file to store secure information and refer to that file in your build files. That file is the keystore properties file.
Read more about this
Is it possible to create this file as it's not available in the github
repo files?
Create a file named keystore.properties in the root directory of your project. This file should contain your signing information, as follows:
storePassword=myStorePassword
keyPassword=mykeyPassword
keyAlias=myKeyAlias
storeFile=myStoreFileLocation
If you do not have store password, key password etc. you should sign your app.
Read more about this
The whole information about this is in the Android Developer documentation, in the link I provided above.

Load google-services.json from local file system

The google-services.json file used by the Firebase Android plugin is usually put in the app's module folder.
What I do want to do instead is put this file somewhere on the filesystem completely outside the project folder and let gradle / the Firebase plugin read it from there.
I thought about putting it's location in the local.properties and somehow 'tell' the Firebase plugin to get the location of the google-services.json from there.
How can I achieve this?
According to offical documentation, the google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module). As of version 2.2.0 the plugin supports build type and product flavor specific JSON files. All of the following directory structures are valid:
// dogfood and release are build types.
app/
google-services.json
src/dogfood/google-services.json
src/release/google-services.json
...
Note: Providing a google-services.json file in the release directory allows you to maintain a separate Firebase project for your production APKs.
When product flavors are in use these more complicated directory structures are also valid.
// free and paid are product flavors.
app/
google-services.json
src/dogfood/paid/google-services.json
src/release/free/google-services.json
...
As a conclusion, you cannot add google-services.json file outside your project.
Hope it helps.

How to configure Firebase to support Android flavors?

I want to use Firebase push notifications, but I am running into a configuration conflict. I would like to support different packages. With Google Maps, for example, I can add multiple packages under one app. This is because of Flavors. If My app package is com.example, I may have multiple Flavors such as com.example.a, com.example.b. I want to add support for push notifications for all of these Flavors.
How do I add multiple package names on the Firebase console?
You dont need to create a seperate google-services.json file for each Flavour,
just add the app to the Firebase Project and redownload the generated google-services.json file.
when you add an app the to the firebase Project, it automatically update the google-services.json file with the Client info you have added, so all you need is to download and replace your old one.
Just create seperate google-services.json files for each package you have and put them in their respective src folders

Categories

Resources