com.myweb.example was my package name, and it was registered in firebase console.
I changed the package name to com.example.newweb, and added a new app in same firebase project with different package name, now when i download google-services.json file, it still shows the old package name in it.
Hence app does not connect with firebase project.
However package name does changes in these 2 places. In rest of 4 places it shows old package name in google-services.json file.
"client_info": { }
"oauth_client": []
I need to know why its showing the old package name in a new app in firebase console.
In google-services.json file contains multiple clients as your apps. so please check the clients key in google-services.json.
this contains all your client apps
{
"client": [
{
"client_info": {
"android_client_info": {
"package_name": "******001" // first app package name
}
}
},
{
"client_info": {
"android_client_info": {
"package_name": "******002" // second app package name
}
}
}
]
}
Related
I am using google-services.json file in my app. There is a field in this file
...
"client": [
{
"client_info": {
"mobilesdk_app_id": "my_id",
"android_client_info": {
"package_name": "my_package_name"
}
},
...
Then in order to distinguish between release and debug I added this line in my .gradle file
debug {
...
applicationIdSuffix ".debug"
}
And then I get an error in debug build that my package name in google-services.json not the same with my package name. And I understand this issue, because in google-services.json package name is my_package_name, but after I added that line in my .gradle file my package name in debug build is my_package_name.debug it is not the same.
So, it is means that now I need every time when I switch between release and debug I need go to google-services.json and change it as well.
I almost sure that here should be solution, question is - how to do it correctly? In order to avoid open google-services.json every time when I switch build variant?
You can add another app with .debug suffix to your Firebase project.
So your new google-services.json file will contain both these apps like this:
"client_info": {
"mobilesdk_app_id": "...",
"android_client_info": {
"package_name": "com.company.project.debug"
}
},
"client_info": {
"mobilesdk_app_id": "...",
"android_client_info": {
"package_name": "com.company.project"
}
}
Reference: https://firebase.googleblog.com/2016/08/organizing-your-firebase-enabled-android-app-builds.html
google-services.json file allows several entries for different app flavours that you have. Just go into the Firebase Console and add the new app, set its name to my_package_name.debug. I have about 6-7 different package names for the same app, it just adds another entry in your generated json.
This question already has answers here:
google-services.json for different productFlavors
(28 answers)
Closed 5 years ago.
I got the following warnings.
How can I avoid this warnings?
Could not find google-services.json while looking in
[src/flavor1/debug, src/debug, src/flavor1] Could not find
google-services.json while looking in [src/flavor1/release,
src/release, src/flavor1] Could not find google-services.json while
looking in [src/flavor2/debug, src/debug, src/flavor2] Could not find
google-services.json while looking in [src/flavor2/release,
src/release, src/flavor2]
I added two client_info at app/google-services.json
{
"project_info": {
"project_number": "000000000000",
"project_id": "****-*****"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": ...,
"android_client_info": {
"package_name": "flavor1.package.name"
}
},
...
},
{
"client_info": {
"mobilesdk_app_id": ...,
"android_client_info": {
"package_name": "flavor2.package.name"
}
},
...
}
],
"configuration_version": "1"
}
As per my experience, this will occur when you are using any type of service related to firebase and you have not put the google-services.json the file which we needed to use the service,
The solution is you need to get the file from firebase console and you need to put inside of your app level folder if you are creating a single project in the console for all flavor and If you are creating different one then you need to create a number of files for a number of projects or flavors.
Could not find google-services.json while looking in
According to LOGCAT, google-services.json is absent in right place (Missing).
The google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module).
Read official guideline about Adding the JSON
For example, dogfood and release are build types.
app/
google-services.json
src/dogfood/google-services.json
src/release/google-services.json
...
Finally, Clean-Rebuild-Run.
I has project with 2 build types.
Every build type has specific applicationIdSuffix.
BuildType : dev , applicationIdSuffix = .dev
BuildType : prod , applicationIdSuffix = .prod
In Firebase console I create application for build type = dev.
As result I download file google-services.json. I put it in c:\myproject\android\app\
In this file "package_name": "com.myproject.dev"
OK. It's work.
Now I in Firebase for the same project, I need to create another application with another buildType = prod.
As result I download NEW file: google-services.json.
In this file "package_name": "com.myproject.prod"
Where I need to put this second file google-services.json?
Firebase already supports that, you should create a new project, then add 2 new apps for each build type (mypackage.prod and mypackage.dev) or flavor.
Once done, just export the google-services.json of the last created app (dev), the file should contain details of both apps, like the following
"client_info": {
"mobilesdk_app_id": "...",
"android_client_info": {
"package_name": "mypackage.dev"
}
},
"client_info": {
"mobilesdk_app_id": "...",
"android_client_info": {
"package_name": "mypackage.prod"
}
You just need to replace the google-services.json with existing one.Because Firebase automatically generates all the necessary attributes in google-services.json file having multiple build flavors in single project
Just remember every-time download new google-services.json and replace it after adding new flavor in your existing project
Im not sure how to use the google-services.json file. There is already a file in my project for a few months now. It looks like this:
{
"project_info": {
"project_number": "212111118",
"project_id": "firebase-myapp"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:222222508:android:111118473",
"android_client_info": {
"package_name": "com.mypackage.myapp"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "abcd1234werwerwersdfdJXo"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
}
],
"configuration_version": "1"
}
Now i put analytics all over my code in andriod. I am using google analytics. Do i need to update this file ? if so how ? Someone in the company gave me a few tracker Ids but no update to the json file. Should it need to be updated ?
Also what i have done is created two build variant folders. One for debug and one for release. there just folders under the src folder. In there i have put strings for the trackings (rollup and mobile tracking) both for debug and release. so do i need google-services.json files for both these folders now ?
If you know the google-services.json generated!Add different service the file is different.It will help you.
Debug and release just need one file.
Some google servies only when the apk release in google play store then they work fine!
Configure your application with google services (In your case your application already have configured the information just open the page, login with configure google account then select your appliciton) link to open the page
My current environemnt already has a google-services.json file and everything works. But now due to unforeseen circumstance i must rename the package of my project. I have successfully renamed the package now. I also went into the google-services.json file and renamed the package name there as well. So now i am wondering do i need to go back onto the google developer site and create a new configuration file ?
Basically i am concerned that renaming the package namein google-services.json is not sufficient. i think that configuration is tied to the original package name. I am wondering when a developer renames the package name of a project is it necesaary to generate a new configuration file from google developer site ?
Here is the google-services.json file i originally generated and i'll show you how i changed the package name :
{
"project_info": {
"project_number": "987654321",
"project_id": "firebase-project_myapp"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:234567:android:1011212314151617",
"android_client_info": {
"package_name": "com.NewPackageName" //i updated package name
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "adlskfjsd;fjkalskdjfalk;sdfj"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
}
],
"configuration_version": "1"
}
Again is it sufficientn to to only update package_name in the json file or do i need to create all new projects for my app ?
Changing the package name in the google-services.json file will not work as it does not act as an update mechanism of any sort but merely a repository of data to be used during services instance establishment.
Yes, it is necessary to create a new configuration file by creating a new application or by deleting the current application in the console you can re-use the application name originally used. This is because each google services instance are generated specifically for a particular application tied to the package name with specific identifiers. So it is an absolute necessity to create a new application and use the google-services.json file from that application settings.
It worked for me by just renaming the package from the googleservices.json file.
We need add an app in firebase-console inside the project with new package name and then download and replace that json in the project directory.
Worked for me!