HCP works on browser, but not on Android app

I have server and app built on meteor 1.8.1.

When I build the server with changed content in the public folder, if I had any browser open on the server URL, it refreshes and shows the updated public content.

But, android apps do not detect the update. Even if I close, run or uninstall+install, the app never detect update.

I have done a full meteor uninstall, install, reset, remove platform, add platform etc. Nothing works.

I have also added the “meteor add cordova:cordova-plugin-meteor-webapp@1.7.0”

Android log shows some errors like cordova.js not found in bundle etc.

The app works perfectly though. Just the HCP does not work on public folder content change.

08-19 16:07:16.775 24331 24331 W MeteorWebApp: Loading asset bundle from directory file:///android_asset/www/application
08-19 16:07:16.814 24331 24331 D MeteorWebApp: Initial bundle loaded dcbda88356768b5995eb01252953c33e8792f5ab
08-19 16:07:16.815 24331 24331 D MeteorWebApp: Detected new bundled version, removing versions directory if it exists
08-19 16:07:16.879 24331 24331 D CordovaWebViewImpl: >>> loadUrl(http://localhost:12712/)
08-19 16:07:16.895 24331 24331 D CordovaActivity: Started the activity.
08-19 16:07:16.900 24331 24331 D CordovaActivity: Resumed the activity.
08-19 16:07:16.907 24373 24410 I chromium: [INFO:library_loader_hooks.cc(51)] Chromium logging enabled: level = 0, default verbosity = 0
08-19 16:07:16.936 24331 24388 W MeteorWebApp: Asset / found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application
08-19 16:07:17.022 24331 24414 I chatty  : uid=10312(com.quranerkotha.app) Chrome_InProcGp identical 2 lines
08-19 16:07:17.230 24331 24331 D CordovaWebViewImpl: onPageDidNavigate(http://localhost:12712/)
08-19 16:07:17.292 24331 24402 W MeteorWebApp: Asset /__cordova/a8716fc383e1d6798d1d2f74c7a1efa133561b90.css found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application
**08-19 16:07:17.296 24331 24402 W MeteorWebApp: Asset /cordova.js not found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application, no parent bundle**
**08-19 16:07:17.299 24331 24402 W MeteorWebApp: Asset /__cordova/a8d580dfb116687d638680181d41e5be31e2912e.js found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application**
**08-19 16:07:17.369 24331 24388 W MeteorWebApp: Asset /cordova_plugins.js not found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application, no parent bundle**
**08-19 16:07:17.380 24331 24388 W MeteorWebApp: Asset /plugins/cordova-plugin-meteor-webapp/www/webapp_local_server.js not found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application, no parent bundle**
**08-19 16:07:17.383 24331 24388 W MeteorWebApp: Asset /plugins/cordova-plugin-statusbar/www/statusbar.js not found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application, no parent bundle**
**08-19 16:07:17.390 24331 24388 W MeteorWebApp: Asset /plugins/cordova-plugin-splashscreen/www/splashscreen.js not found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application, no parent bundle**
08-19 16:07:17.396 24331 24388 W MeteorWebApp: Asset /plugins/onesignal-cordova-plugin/www/OneSignal.js not found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application, no parent bundle
08-19 16:07:18.295 24331 24331 D CordovaWebViewImpl: onPageFinished(http://localhost:12712/)
08-19 16:07:18.360 24331 24386 W MeteorWebApp: Asset /index/index.html found in bundle dcbda88356768b5995eb01252953c33e8792f5ab:file:///android_asset/www/application
08-19 16:07:18.372 24331 24331 D SystemWebChromeClient: http://localhost:12712/__cordova/a8d580dfb116687d638680181d41e5be31e2912e.js?meteor_js_resource=true: Line 135 : Application startup
08-19 16:07:18.376 24331 24331 D SystemWebChromeClient: http://localhost:12712/__cordova/a8d580dfb116687d638680181d41e5be31e2912e.js?meteor_js_resource=true: Line 135 : Initialize onesignal
08-19 16:07:18.440 24331 24435 W PluginManager: THREAD WARNING: exec() call to OneSignalPush.init blocked the main thread for 59ms. Plugin should use CordovaInterface.getThreadPool().
08-19 16:07:18.443 24331 24331 D SystemWebChromeClient: http://localhost:12712/__cordova/a8d580dfb116687d638680181d41e5be31e2912e.js?meteor_js_resource=true: Line 135 : Initialized onesignal

I tried calling WebAppLocalServer.checkForUpdates(); manually. But I can see this exception:

08-19 16:07:19.368 24331 24445 W MeteorWebApp: Download failure
08-19 16:07:19.368 24331 24445 W MeteorWebApp: com.meteor.webapp.WebAppException: Error parsing asset manifest
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at com.meteor.webapp.AssetManifest.<init>(AssetManifest.java:80)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at com.meteor.webapp.AssetBundleManager$1.onResponse(AssetBundleManager.java:112)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: 	at java.lang.Thread.run(Thread.java:764)
08-19 16:07:19.368 24331 24445 W MeteorWebApp: Caused by: org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject

The app is definitely connected to the server. I can call APIs on the server. So, the server is running and receiving calls from the apps.

Can you confirm that your manifest is not being cached when you upgrade your code?

website.com/__cordova/manifest.json

Also check that your manifest has the correct format

2 Likes

Well remembered @rjdavid.

@oazabir, check out this thread: https://github.com/meteor/meteor/issues/10277. You’ll see at the bottom of that thread that I had accidentally introduced a WebApp.rawConnectHandlers.use call which added a cache-control header to all .json files.

A quick test for this is as @rjdavid suggests - open the manifest.json file directly in Chrome and look at the repsonse headers to see if there are any cache-control headers.

In my case iOS was obeying the headers (breaking HCP) and Android was ignoring the headers (allowing HCP), but your experience here is the opposite. Your subject line states that HCP isn’t working in Android. What about iOS?

1 Like

Thank you for looking at this issue. I found that I needed to add android platform on the server, in order for the __cordova endpoint to be generated. Now that solves the initial problem. I have a new problem now.

Error: appId in downloaded asset bundle does not match current appId. Make sure the server at https://app.quranerkotha.com/ is serving the right app

This error comes from WebAppLocalServer.checkForUpdates() call.

Full stack

MeteorWebApp: 	at com.meteor.webapp.AssetBundleDownloader.verifyRuntimeConfig(AssetBundleDownloader.java:205) MeteorWebApp: 	at com.meteor.webapp.AssetBundleDownloader$1.onResponse(AssetBundleDownloader.java:113) MeteorWebApp: 	at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153) MeteorWebApp: 	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) MeteorWebApp: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) MeteorWebApp: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) MeteorWebApp: 	at java.lang.Thread.run(Thread.java:764) MeteorWebApp: Download failure MeteorWebApp: com.meteor.webapp.WebAppException: appId in downloaded asset bundle does not match current appId. Make sure the server at https://app.quranerkotha.com/ is serving the right app. MeteorWebApp: 	at com.meteor.webapp.AssetBundleDownloader.verifyRuntimeConfig(AssetBundleDownloader.java:205) MeteorWebApp: 	at com.meteor.webapp.AssetBundleDownloader$1.onResponse(AssetBundleDownloader.java:113) MeteorWebApp: 	at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153) MeteorWebApp: 	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) MeteorWebApp: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
MeteorWebApp: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
MeteorWebApp: 	at java.lang.Thread.run(Thread.java:764)

I can see the __cordova/manifest.json is generating unique appId, which is probably not matching with the appId specified in the app in mobile-config.js.

How can I fix the appId in __cordova/manifest.json?

OK, I found the way to set APP_ID environment variable. Now, the server side has got a fixed App Id.

Problem is now with Androind app build. It is getting random App ID generated.

console.log("Application startup: " + meteor_runtime_config.appId);

Shows randomly generated app ID. How do I fix this?

I have tried passing --mobile-settings to meteor build command, hoping it would take the mobile-config.js and apply the App Id from there. But doing that gives me this error during build:

While processing mobile-config.js:
<anonymous>: Unexpected token A in JSON at position 0
at JSON.parse (<anonymous>)
at makeOptimistic (/tools/fs/optimistic.js:247:17)
at wrap.makeCacheKey (/tools/fs/optimistic.js:25:15)
at optimistic
(/home/newuser/.meteor/packages/meteor-tool/.1.8.1.ani1yi.p0f9s++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/optimism/src/index.ts:80:31)

The js file is definitely valid.

App.info({
  id: 'com.quranerkotha.app',
  name: 'কুরআনের কথা ',
  description: 'আধুনিক মানুষের জন্য সমসাময়িক প্রশ্ন, দ্বন্দ্ব এবং ঘটনাগুলোকে কুরআনের আলোকে দেখা এবং কুরআনের আয়াতে লুকিয়ে থাকা বৈজ্ঞানিক তথ্য এবং যুক্তির উপর আলোচনা',
  author: 'Omar AL Zabir',
  email: 'omaralzabir@gmail.com',
  website: 'https://app.quranerkotha.com',
  version: '1.4.8'
});