Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[xdl] Do not override google-services.json contents since SDK37 #1897

Merged
merged 3 commits into from
Apr 17, 2020

Conversation

sjchmiela
Copy link
Contributor

@sjchmiela sjchmiela commented Apr 16, 2020

Why

Following Using FCM doc or GoogleSignIn - Usage with Firebase part would not render the expected results — googleSignIn configuration was always being applied onto google-services.json, even if a custom one has been provided by the user. Most probably this is not how this should work or what the user expect.

When pushed to Turtle builders, should fix expo/expo#7727.

How

Depending on the SDK version of the built project:

  • if the SDK is >= 37:
    • only change google-services.json if none was provided (so we're operating on a placeholder one)
    • if both configuration settings are provided print a warning and not modify the custom google-services.json
  • if the SDK is < 37:
    • if the user provides a custom googleServicesFile, print a warning that its contents are about to be modified,
    • always modify google-services.json, as it has been working before.

I have also moved the replace "host.exp.exponent" with ${javaPackage} to where the logic above is mentioned so that all google-services.json modifications are in one place.

Test plan

  • SDK37, only googleServicesFilejob, no warning, used google-services.json
  • SDK37, only googleSignInjob, no warning, uses placeholder project ID and googleSignIn key
  • SDK37, both provided — job, warning present (google-services.json overrides others), used google-services.json
  • SDK36, only googleServicesFilejob, no warning, removed key from google-services.json force-pushed version where the warning should be printed and the key still removed
  • SDK36, only googleSignInjob, no warning, used googleSignIn and leaking project ID
  • SDK36, both provided — job, warning present (google-services.json overridden), google-services.json overridden

@sjchmiela sjchmiela force-pushed the @sjchmiela/google-services-json-fix branch from 00d81d5 to 7354b70 Compare April 16, 2020 11:37
@sjchmiela sjchmiela changed the title [xdl] Do not override google-services.json contents from SDK37 [xdl] Do not override google-services.json contents since SDK37 Apr 16, 2020
@codecov-io
Copy link

codecov-io commented Apr 16, 2020

Codecov Report

Merging #1897 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1897   +/-   ##
=======================================
  Coverage   60.77%   60.77%           
=======================================
  Files          84       84           
  Lines        2598     2598           
  Branches      719      719           
=======================================
  Hits         1579     1579           
  Misses        996      996           
  Partials       23       23           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d849b5...5116402. Read the comment docs.

@sjchmiela sjchmiela marked this pull request as ready for review April 16, 2020 11:45
@sjchmiela sjchmiela requested a review from dsokal April 16, 2020 11:45
@MarzV
Copy link

MarzV commented Apr 16, 2020

@sjchmiela, First of all, thnkz for addressing this issue, lot of people depend on this feature. But can can you please eleborate on this a bit more in detail in the scenario that a build is made with SDK 36

Before this issues was raised, I did not have the extra code in my app.json for the google.service.json. I mean this snippet of code:

"android": {
"package": "secret",
"googleServicesFile": "./google-services.json",
"config": {
"googleSignIn": {
"apiKey": "xxxxxxxxxxxxxxxx"
}
},
"versionCode": 1
},
}

But after the moment issues where raised that pushtoken was no longer set for standalone apps. there was a suggestion that adding the above code would fix the problem, so I did.

Question: When building with SDK 36 do we still need to add the above extra snippet of code, even when before it was not there and everything worked just fine. Or do we now always need to add this extra code snippit to the app.json file.?

Your answer is much appreciated

packages/xdl/src/detach/AndroidShellApp.js Outdated Show resolved Hide resolved
@sjchmiela sjchmiela merged commit 00ee89b into master Apr 17, 2020
@sjchmiela sjchmiela deleted the @sjchmiela/google-services-json-fix branch April 17, 2020 07:58
sjchmiela added a commit to expo/turtle that referenced this pull request Apr 20, 2020
#209)

<!-- Thanks for contributing to _turtle_! Before you submit your pull request, please make sure to check the following boxes by putting an x in the [ ] (don't: [x ], [ x], do: [x]) -->

### Checklist
- [x] I've read the [Contribution Guidelines] (https://github.com/expo/turtle/blob/master/CONTRIBUTING.md).
- [x] I've updated the [CHANGELOG](https://github.com/expo/turtle/blob/master/CHANGELOG.md) if necessary.
- [x] I've ensured the unit and smoke tests are still passing - either by running `yarn test:unit` and `yarn test:smoke:[ios|android]` or by checking the appropriate CircleCI builds' statuses.
- [x] **I've manually tested whether the changes I made work as expected.**

### Motivation and Context

- `google-services.json` was being handled unintuitively, fixed with expo/expo-cli#1897
- Expo Client's secrets were leaking in shell apps, fixed with expo/expo#7768
- When deployed, fixes expo/expo#7727.

### Description

XDL was modifying `google-services.json`, removing valid keys if the user doesn't provide the same, removed key in _some other place_ (see expo/expo#7727 (comment)). Fixed the change in XDL, upgraded to the fixed version here. Also removed secrets from the shell app.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDK37 standalone app: "Couldn't get GCM token on device"
4 participants