From d49bb502859194dd400284225797b8aae669487c Mon Sep 17 00:00:00 2001 From: Jonathan Ferreira <44679989+Jonathansoufer@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:45:17 +0100 Subject: [PATCH] fix: android firebase docs template (#11512) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR implements a fix for the build issue while building for Android using the google service template. ## **Related issues** Fixes: [This](https://consensys.slack.com/archives/C02U025CVU4/p1721032064262819?thread_ts=1720795465.311619&cid=C02U025CVU4) ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Charly Chevalier --- README.md | 11 ++++++++--- android/app/google-services-example.json | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 64eff4aa1df..2c4a6de0445 100644 --- a/README.md +++ b/README.md @@ -41,15 +41,20 @@ cd metamask-mobile **Firebase Messaging Setup** -Before running the app, keep in mind that MetaMask uses FCM (Firebase Cloud Message) to empower communications. Based on this, would be preferable that you provide your own Firebase project config file and update your `google-services.json` file in the `android/app` directory as well your .env files (ios.env, js.env, android.env), adding GOOGLE_SERVICES_B64 variable depending on the environment you are running the app (ios/android). +Before running the app, keep in mind that MetaMask uses FCM (Firebase Cloud Message) to empower communications. Based on this, as an external contributor you would preferably need to provide your own FREE Firebase project config file with a matching client for package name `io.metamask`, and update your `google-services.json` file in the `android/app` directory as well your `.env` files (`.ios.env`, `.js.env`, `.android.env`), adding `GOOGLE_SERVICES_B64` variable depending on the environment you are running the app (ios/android). -ATTENTION: In case you don't provide your own Firebase project config file, you can make usage of a mock file at `android/app/google-services-example.json`, following the steps below from the root of the project: +The value you should provide to `GOOGLE_SERVICES_B64` is the base64 encoded version of your Firebase project config file, which can be generated as follows: ```bash base64 -i ./android/app/google-services-example.json ``` -Copy the result to your clipboard and paste it in the GOOGLE_SERVICES_B64 variable in the .env file you are running the app. +Copy the result to your clipboard and paste it in the `GOOGLE_SERVICES_B64` variable in the `.env` file you are running the app. + +> [!CAUTION] +> In case you don't provide your own Firebase project config file, you will face the error `No matching client found for package name 'io.metamask'`. + +You can make usage of a mock file at `android/app/google-services-example.json`, following the same steps above from the root of the project. In case of any doubt, please follow the instructions in the link below to get your Firebase project config file. diff --git a/android/app/google-services-example.json b/android/app/google-services-example.json index 56d9bd48e3c..f7765f0ad2a 100644 --- a/android/app/google-services-example.json +++ b/android/app/google-services-example.json @@ -7,15 +7,20 @@ }, "client": [ { + "api_key": [ + { + "current_key": "" + } + ], "client_info": { "mobilesdk_app_id": "1:123456789000:android:f1bf012572b04063", - "client_id": "android:com.google.samples.quickstart.admobexample", + "client_id": "android:io.metamask", "client_type": 1, "android_client_info": { - "package_name": "com.google.samples.quickstart.admobexample", + "package_name": "io.metamask", "certificate_hash": [] } - }, + } } ], "configuration_version": "1"