I have a app with Google Sign-In integrated with Firebase. I recently changed app package name for release purpose. and now running throwing this error:
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name '<Package Name>'
So I am guessing Firebase cant recognize app with the new package name. How can I change Firebase package name. I have gone through Firebase console but can't find any changing package settings. Or is there any good way to achieve this instead of creating new project with package name and code again? Any help would be appreciated.
As Eurosecom commented, you can just add a new Android app to your existing Firebase project with the new package name. After doing this, download the updated google-services.json and add it to your app.
Note that Firebase does not use the actual package name from your Java code, but uses the applicationId from your app's build.gradle file:
defaultConfig {
applicationId "com.firebase.hearthchat"
When you initially create a project in Android Studio, the package name and application id will have the same value. But if you refactor your code into a different package, the application id won't be updated. That explains why the app will continue to work after such a refactoring. But it can be confusing at times, which is why I prefer keeping them in sync.
If you are using Firebase assistant then:
Delete your app in the Firebase console in the project settings.
Back in Firebase assistant reconnect to the Firebase for any service.
It will ask you to sync with the project. Click on Sync.
The app with new package will be added and the google-services.json file will be automatically updated.
Also note that the package name of the applicationId value in the build.gradle file is considered.
Cheers
There's a better way of resolving this issue.The error can be as result of you having a GoogleService Json file in your app folder, All you need to do is; try and locate your google-service.json file under app folder, and change the package_Id to the new package_id you have created; Save, Do a Clean and Rebuild Project, your problem would be resolve. Hope this will help you. It works for me. You can kindly votes if this also help you. Thanks
Related
I'm new to Android development.
I finally finished up my first android application and
tried to upload on google play.
then I found out I can't use com."example" package name for uploading.
so I already changed all my package name to com."◯◯◯" and it worked fine.
but once I changed applicationId in gradle app file which corresponds to the package name, my app is not installed any more...
there's no error message in android studio and seems to fine.
I did clean and rebuild, invalidate caches/restart, uninstall existing app on my device, etc..but any of them not working.
I couldn't find any solution for it. please help me to fix this problem.
thank you
---update. case solved---
It was because if you change the applicationId, the installed app is brand new one(doesn't have any data in the database). so the problem was null variable which I didn't make it nullable.
thank you for your help.
change all place-name where package name use it then try
I want change the package name in flutter, for the existing project which is using firebase and firebase cloud functions in the project.
According to this article,
Click here for the article
I have downloaded the new google-services.json file with new package name works fine.But is the right method to change the package name? for production apps
P.S: Suggest an edit if there's anything wrong with the question
Thanks for the help in advance :)
There is a simple method to change package name in flutter, simply add change_app_package_name to your dependency and run the following command
flutter pub run change_app_package_name:main com.new.package.name
where com.new.package.name is your new package name.
I had GCM implemented and I am trying to import GCM to FCM now. I dont want to use google-services.json because I want to use different google projects for different environments(Dev, Stag, Prod).
I tried to initialize the app via this code below
FirebaseOptions.Builder options=new FirebaseOptions.Builder();
options.setGcmSenderId("<<project id>>");
options.setApplicationId("<<Project name>>");
FirebaseApp firebaseApp = FirebaseApp.initializeApp(getApplicationContext(),options.build(),"MyTestFCM");
String refreshedToken= FirebaseInstanceId.getInstance(firebaseApp).getToken();
I keep getting exception on Firebase App initialization
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. Available app names: MyTestFCM
If I remove the app name then i dont get a token back, then when I re-run the application I get a token. I have tried to execute the above piece of code from Mainactivity and Application class. In both places I get the same error.
So my question is how do I initialize Firebase application without using google-services.json
Thanks,
P
Firebase SDK requires to have a "default" project configured via google-services.json
Once you have that you can register FCM sdk with other sender-id using the FirebaseInstanceId.getInstance(context).getToken(...)
But please note that the most recent FCM features (auto-retry of the registration, topic subscriptions) only work with the default project.
So turns out that you need to use google-services.json for FCM, and to handle multiple build variants situation,
Generate respective google-services.json from the firebase console for the different build variants.
Download the google-services.json
In your project create folders for the variants, for example if you want release build, create a folder with name "release" and place the google-services.json in it.
When the app builds, depending upon the build variant it looks for google-services.json in the respective folder and picks up the project details from it.
More details can be found on this thread
google services issues 54
Thanks Arthur Thompson
have you checked to make sure to set your FIREBASE_URL to the right string? Also did you make sure to have the appropriate app setup config?
Last time this happened, I needed to set up my Android App Configs.
https://support.google.com/firebase/answer/7015592
Afterwards, you can follow this setup.
https://firebase.google.com/docs/cloud-messaging/android/client
Please do double check, you added
apply plugin: 'com.google.gms.google-services'
at the bottom of app's gradle file and then clean and rebuild the project
When I attempt to upload my apk then everytime I get the following error:
"Upload error
UPLOAD NEW APK TO PRODUCTION
Upload failed
You need to use a different package name because "com.google" is restricted."
When I rename or refactor based on the multiple different steps suggested on this site to change "com.google.samples.apps.myapp" it breaks the program in a manner which then prevents it from a successful "build"
I have read and reread: "com.example restricted" Google Play error; even when changing the package name AND also
Android Studio Rename Package
I suspect that the refactor does not correct the links I need to the R file? Any help would be appreciated.
If you're using Android Studio / Gradle you don't need to change your package name (as it impacts your resources) but only the "applicationId" which is whats used for publishing.
Details here: http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename
I want to know if package name, defined on Firebase project console, is tightly related to Firebase Cloud Message successful delivery or it's just a helper for creating google-services.json file.
On Firebase console, once created it can't be renamed.
In my case I created a project at Firebase console named, by mistake, son.example.firecm instead of com.example.firecm as defined on my Android Studio Project.
My Android project was not compiling cause gap on spelling at google-services.json.
Once renamed package name to com.example.firecm, it compiled but not sure if it will receive Firebase Cloud Messages or not cause difference between Firebase console project package definition at Android Studio project.
Having the right package name is important for several services, though not FCM specifically, other than getting it right in the google-services.json as you found. FCM uses the project number to identify the app, which will be read from the JSON file.
The best thing to do is just to connect a new Android app to your Firebase project with the correct package name, and download the updated google-services.json. It wont hurt to have the other package name connected (and once the console allows deleting connected apps, you should be able to remove it).
Well I did further research on the same.
I found that if package name defined on Firebase Console isn't the same as defined on Gradle and Manifest of the APP, then the APP won't be able to receive Notifications sent from Firebase Console.
In guess that in some way it's logic that package name must match in order to Android lunch the correct APP once notification arrives.
To sumarize, it's mandatory that both names matches.
I invite to test by yourself and keep and eye on package names for project success.