After struggling for a couple of days with a seemingly elusive bug, I’d like to share what happened and suggest a couple of small improvements in the guide that would have made finding the issue much easier:
What I experienced was very weird: When running on android with
meteor run everything was fine. But when building an apk with
meteor build and installing it (via adb or the play store) the app had extremely long load times for the first run, sometimes ending with complete stuckness. When reloading the app the second time was usually working fine - but sometimes not.
For a while I believed that this has to do with the launch screen package and tried some manipulations there. But after a while I realized it’s not that.
The first real smart thing I did was to build a debug apk and inspect it on my device with chrome. And here is my first suggestion: Explain in the guide how to do exactly this. Creating a debug apk (which is the only way to later debug an apk with the chrome devtools) is not documented anywhere in the mobile guide and yet it’s an incredibly powerful tool which I’m super glad I found out about.
Actually, the --debug flag is also not documented in the build tool guide. If searching for “meteor build” or “meteor build --debug” on google you get either to the above-linked guide or to this page which are not useful for this at all. So the only place you can learn about it is in command line help
meteor build --help.
In short, what I’m trying to say here is that there’s a very powerful tool for mobile development in hiding .
After successfully building debug.apk (took me a bit also to realize it’s not release-unsigned.apk when using the --debug flag, this isn’t documented in the command line --help) and installing it, the rest was easy: my Meteor.settings was undefined, which caused errors where in the first pages of my app I’m using Meteor.settings.public.
It was undefined because I was building my app using this line:
meteor build ~/build-output-directory --server <host>:<port>
Which is the canonical example in the guide. I did not add a --mobile-settings flag. This caused the first run of the app to throw errors, and the second run to work ok since it was already after a hot code push with the settings on the server. Once I realized that this was the problem everything was fixed.
And here is my second suggestion:
the --mobile-settings flag isn’t even mentioned in the mobile guide. It should definitely be there.
That’s it. Sorry for the long rant and thanks a lot for a wonderful platform!!