New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK37 standalone app: "Couldn't get GCM token on device" #7727
SDK37 standalone app: "Couldn't get GCM token on device" #7727
Comments
+1 this issue |
Same happening here |
Hm, ok, so, at first (in the issue where I asked you to create another one) I understood the "production application" as a standalone application built using Did/do you mean "apps in production mode running in Expo Client"? If so I'm sorry I put you through the process of creating a new issue—it is totally related to the original. Next time I will make sure to understand a comment correctly before asking to create another issue. 🙂 Good news is that both #7653 and this should be resolved in the latest release of Expo Client for Android — v2.15.1. Cross-posting from #7653 (comment):
Let me know if this has resolved your problem and my understanding is correct, if not, we'll get down to debugging! |
For my case, I have the issue with a standalone application, available through app stores and not running in Expo Client. |
Same; the app is deployed via Travis using the |
Sorry for the misleading title! 😄 |
+1 this issue |
+1. This issue appears to have started with our upgrade to SDK 37. Issue exhibiting for us on Android standalone. |
I have reproduced the error and I think I have also found a workaround. Could you, please, try:
ExampleFor a {
"project_info": {
"project_number": "…",
"firebase_url": "…",
"project_id": "…",
"storage_bucket": "…"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "…",
"android_client_info": {
"package_name": "…"
}
},
"api_key": [
{
"current_key": "KEY_KEY_KEY_KEY_KEY"
}
]
}, please make {
"expo": {
"…": "…",
"android": {
"package": "…",
"googleServicesFile": "./google-services.json",
"config": {
"googleSignIn": {
"apiKey": "KEY_KEY_KEY_KEY_KEY"
}
} |
@sjchmiela Your fix worked for our production standalone app. Much appreciated. |
@sjchmiela I can confirm your fix works for our production standalone app. Greatly appreciated (just to one-up @RoninSTi) |
I really appreciate this. Thank you. |
Working for me as well :) Thanks a lot for your work. |
Any update on this? |
expo team should add this step to docs! thanks anyway |
Yea, they should! Took me hours to find out. |
This is really bad practise not to mention this by the expo team |
it took me about 49 hours to figure out a solution! and I needed to rebuild apk to users |
FWIW I needed to publish a new version to the Google Play store; just publishing to Expo wasn't able to provide OTA changes about the Thanks @sjchmiela for putting together a workaround! |
Hey the issue for me is not resolved with the fix @sjchmiela suggested. Everything was working fine before the update to SDK 37, and as you can see in my dev settings, I am still working with the sdk 36. In a expo managed app, so its not ejected I am testing the STANDALONE app on browserstack. This is the log from cradle: I presume this is where things go wrong. As you probably can see, I use the suggested solution with the googleSignIn key, but there is not token set when calling await Notifications.getExpoPushTokenAsync(); If I understand the problem correct, this has something todo with the path to google.service.json. Can somebody explain how to set the path correct, or am I missing something else? |
@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": { 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 |
…1897) # Why Following [Using FCM doc](https://docs.expo.io/versions/latest/guides/using-fcm/) or [GoogleSignIn - Usage with Firebase part](https://docs.expo.io/versions/latest/sdk/google-sign-in/#usage-with-firebase) 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 `googleServicesFile` — [job](https://staging.expo.io/dashboard/sjchmiela/builds/4dca157f-3ae5-4739-96a7-2a1fbcf2ec0e), no warning, used `google-services.json` - SDK37, only `googleSignIn` — [job](https://staging.expo.io/dashboard/sjchmiela/builds/2c44d75e-9ce1-4098-ab64-04e76f01efda), no warning, uses placeholder project ID and `googleSignIn` key - SDK37, both provided — [job](https://staging.expo.io/dashboard/sjchmiela/builds/23626002-acf2-4a30-a620-2062f134d671), warning present (google-services.json overrides others), used `google-services.json` - SDK36, only `googleServicesFile` — ~[job](https://staging.expo.io/dashboard/sjchmiela/builds/8366c022-dcff-4047-bf0a-0264a52870a1), no warning, **removed key from google-services.json**~ force-pushed version where the warning should be printed and the key still removed - SDK36, only `googleSignIn` — [job](https://staging.expo.io/dashboard/sjchmiela/builds/d59e4334-a815-4d6a-8ba2-108ab2f5d8bc), no warning, used `googleSignIn` and leaking project ID - SDK36, both provided — [job](https://staging.expo.io/dashboard/sjchmiela/builds/d5a8ab8f-07f7-4aac-9c64-7012421d1b49), warning present (google-services.json overridden), google-services.json overridden
I have merged the pull request that fixes the unintuitive behavior in I will answer all the remaining questions once the new version is up on the production Android builders. |
@sjchmiela Thanks much. You Suggestion Worked for me. Any idea why the app crashes while trying to get a push token when the device is not connected to the internet? |
#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.
The upgrade has been just deployed to production Turtle builders! Read on to find out what does it mean for you. What was the issue?There was a bug in the library that is being used to prepare the Android project when building a standalone app—it was always modifying provided The modifications, originally, were supposed to modify a placeholder See the PR fixing at expo/expo-cli#1897. Since the fix is in production, is there something I should do?In fact, yes, if you have applied the workaround described at #7727 (comment), please be advised to remove the If you have a If you don't have a I keep getting "Couldn't get GCM token on device" errorUnfortunately, the changes we're speaking of are interpolated into native resources when the app is built, so it won't be possible to fix the problem using an OTA update. You will need to rebuild your app using I'm getting another error: "Couldn't get push token on device. Check that your FCM configuration is valid."First, check if your FCM configuration is valid, i.e. if your Then, if it is up-to-date, please check in the Google Cloud console if the keys that are used in your app are allowed to communicate with Firebase Installations API. For more information on how to do it, check out #7606 (comment). If it still doesn't work, try restarting the application. It looks like sometimes it takes a restart to trigger the push token update. It probably doesn't depend on us or our code — this may be an intermittent issue with Firebase. If it still doesn't work, please file a new issue on the repository, let's fix this bug! Does the problem come from "Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]"?No, it doesn't a couple lines below you should see a line reading:
Should we add the workaround to the docs?No, as it only has been a workaround until the real issue (with the aforementioned library) was fixed. However, I am really sorry some of you had to spend so much time debugging an issue that wasn't your fault. I, too, know how daunting this can be and I apologize. As always I recommend checking out the issues list here or our forums if you encounter any more blocking (or any other) issues using Expo. Do I need to rebuild the app or will a publish suffice?As Google configuration is included in native resources of the app you will need to do a full rebuild with I'm using an ejected ExpoKit app, is there something I should do?Make sure Try cleaning your project (from Android Studio: Project > Clean Project) and rebuilding. If that doesn't work you can try adding I'm still on SDK lower than 37. How to approach this issue?I was afraid of breaking any behavior that users of previous SDKs may depend on, so I didn't change anything apart from adding a warning. If you're on SDK36 or lower and would like to use your own
The app is crashing when trying to fetch a push token when not connected to the InternetFrankly speaking I haven't experienced it myself, so I don't have any straight-up solution. Would you care to post a new issue on the repo so we can keep the discussion separate? (Posting the build URL would be helpful!) |
I'm locking this thread to make sure @sjchmiela's response above remains as the definitive obvious answer. As he mentions at the end of his comment, if you are encountering an issue that you think is related, please post a new issue on the repo so we can keep the discussion separate and please share the build URL (you can share it privately to secure@expo.io and mention the issue in it if you wish). |
✅ Resolved: jump straight to the solution
The following comment provides a solution and an explanation of the problem: #7727 (comment)
Original post (for reference)
🐛 Bug Report
This extends #7653. Per the request of @sjchmiela , I'm opening a separate issue for where this error is happening in a production environment.
I have confirmed we followed the instructions in this guide to set up Android notifications correctly. Everything was working fine in Expo SDK 35, and then broken once we upgraded to SDK 37.
We're seeing this error in Sentry for ~40 users, all Android, mostly version 28 and 29.
Environment
Below is my dev environment, though we are seeing this error in production.
Build targets are iOS and Android, the issue is for Android only.
Steps to Reproduce
Notifications.getExpoPushTokenAsync()
in native appExpected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: