0

I have checked this and this, and every possible article out there. Even checked Meteor Guide and getting crazy very soon because of this problem!

Problem: The problem is getting Hot Code Push (HCP) to work on device once pushed to ROOT_URL mentioned below.

Environment:

Mac macOS Sierra
Meteor  : 1.5.1
Router  : iron:router@1.1.2
Hosting : Heroku
Deploy Source: GitHub
Cordova : 7.0.1
Android tools target: 23
Buildpack: https://github.com/AdmitHub/meteor-buildpack-horse.git

Buildpack Options:
  BUILDPACK_PRELAUNCH_METEOR = 0
  ROOT_URL: https://grocer-eg.herokuapp.com/

run command:

meteor run android-device -s settings.json --mobile-server https://grocer-eg.herokuapp.com

AND

meteor build --mobile-settings settings.json --server https://grocer-eg.herokuapp.com --debug --directory ../my-output-directory/

Log:

App running at: http://localhost:3000/     
=> Started app on Android Device.             
I20170830-19:43:30.364(3)? int logctl_get(): open '/dev/hwlog_switch' fail -1, 13. Permission denied
I20170830-19:43:30.518(3)? 
I20170830-19:43:30.521(3)? Note: log switch off, only log_main and log_events will have logs!
I20170830-19:43:30.522(3)? 08-30 19:43:09.277 14167 14167 I CordovaLog: Changing log level to DEBUG(3)
I20170830-19:43:30.522(3)? 08-30 19:43:09.379 14167 14167 I chromium: [INFO:library_loader_hooks.cc(144)] Chromium logging enabled: level = 0, default verbosity = 0
I20170830-19:43:30.523(3)? 08-30 19:43:10.121 14167 14167 I MeteorWebApp: Serving asset bundle with version: d723bae98470d4b496c7c54898abf69b06ce144b
I20170830-19:43:30.524(3)? 08-30 19:43:10.498 14167 14263 E chromium: [ERROR:BudgetService.cpp(165)] Unable to connect to the Mojo BudgetService.
I20170830-19:43:30.524(3)? 08-30 19:43:11.490 14320 14380 I chromium: [INFO:library_loader_hooks.cc(144)] Chromium logging enabled: level = 0, default verbosity = 0
I20170830-19:43:30.524(3)? 08-30 19:43:12.253 14167 14167 I chromium: [INFO:CONSOLE(9676)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: http://localhost:12128/packages/jquery.js?hash=e5fc9cebb2e37c48ddfaf76e0ab0b77cb6ce6e52 (9676)
I20170830-19:43:30.525(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp: Download failure
I20170830-19:43:30.525(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp: com.meteor.webapp.WebAppException: Error parsing asset manifest
I20170830-19:43:30.525(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at com.meteor.webapp.AssetManifest.<init>(AssetManifest.java:80)
I20170830-19:43:30.525(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at com.meteor.webapp.AssetBundleManager$1.onResponse(AssetBundleManager.java:112)
I20170830-19:43:30.526(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
I20170830-19:43:30.526(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
I20170830-19:43:30.526(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
I20170830-19:43:30.526(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
I20170830-19:43:30.527(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at java.lang.Thread.run(Thread.java:776)
I20170830-19:43:30.527(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp: Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
I20170830-19:43:30.527(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at org.json.JSON.typeMismatch(JSON.java:111)
I20170830-19:43:30.528(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at org.json.JSONObject.<init>(JSONObject.java:160)
I20170830-19:43:30.528(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at org.json.JSONObject.<init>(JSONObject.java:173)
I20170830-19:43:30.528(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   at com.meteor.webapp.AssetManifest.<init>(AssetManifest.java:39)
I20170830-19:43:30.528(3)? 08-30 19:43:15.121 14167 14505 W MeteorWebApp:   ... 6 more

UPDATED NOTE:

http://localhost:3000/__cordova/manifest.json returns a huge json file successfully, but https://grocer-eg.herokuapp.com/__cordova/manifest.json is routed as not found template!

I have been searching while not understanding 90% of the mentioned articles, and by following each and every recommendation in them.

halfer
  • 19,824
  • 17
  • 99
  • 186
Roshdy
  • 1,703
  • 3
  • 25
  • 34
  • Is this when you are running the APK against your prod server, or are you in development mode? – Mikkel Aug 31 '17 at 12:29
  • I'm running the `meteor run` command on my local machine, but pointing to my production server – Roshdy Aug 31 '17 at 13:32
  • That doesn't sound good. Any requests from the App will go to the prod server, but that's not where the app is being served from, so you have 2 sources of truth, and the HCP will happen from the prod server, I don't think this is what you want – Mikkel Sep 01 '17 at 02:09
  • How do i build/run the apk without referencing the localhost? If you have a solution, kindly share it – Roshdy Sep 01 '17 at 07:23
  • When you are developing you don't need to mention the mobile server, just use `meteor run android-device` There is a trick for building the apk to make sure it works right - I can share that if that's what you are looking for – Mikkel Sep 01 '17 at 09:09
  • No need for my permission to share a trick ;) . As for --mobile-server, how else would it connect to my staging (fake production) server ?! – Roshdy Sep 01 '17 at 12:41

2 Answers2

0

The Meteor build remembers the last setting when you were running locally, which is technically a bug, but never been resolved as there is a workaround.

In order to build an APK, you need to make sure your build area is fresh, this script does that:

#!/bin/bash
#
# Script to generate android apk (pre-cursor)

# Remove previous build (ensures a clean build)
#
rm -rf .meteor/local/cordova-build

# Remove the app from the device (makes installation more reliable)
#
adb uninstall <%=COM_NAME%>

# Run meteor, which will build a debug apk and install it on the device
#
meteor --mobile-server <%=ROOT_URL%> run android-device

This is a template that I use to generate a script for each different environment.

Having done that, your build area is now primed with the URL of your target environment, and the APK on the device is ready for that environment. Now do your build with the same URL:

meteor build --server <%=ROOT_URL%>

It's a little convoluted. I ended up writing a bunch of scripts to allow me to easily manage several environments, once for each development machine, staging, test and production.

You can do all that manually, but it is error-prone. One mistake and you have to start again, and the build and install cycle takes a little time anyway. I could share the scripts with you if you like.

Mikkel
  • 7,693
  • 3
  • 17
  • 31
  • I tried removing the cordova-build folder, I uninstalled the app from my mobile, then ran `meteor run android-device --mobile-server ...`, but i'm still getting the same issue. I believe the problem is from Heroku side! because i can't get a route for `https://grocer-eg.herokuapp.com/__cordova/manifest.json` – Roshdy Sep 02 '17 at 07:36
0

So apparently i was doing nothing wrong except using the buildpack i was using.

The problem with the build pack is that it was removing the android platform before running meteor here and here

So i just forked it and commented out these lines, and it worked as expected.

Now i have HCP working :D

Roshdy
  • 1,703
  • 3
  • 25
  • 34