Embedded Cordova app bundle is being opened in Chrome instead of launching within my Android app

Viewed 34

I'm working on a project where a Cordova app is embedded within a native app. At the point where the Cordova app is supposed to be loaded into the Activity that's hosting it, I instead see Chrome open up with the URL of the app bundle. What could be causing this?

In logcat, when I filter for "cordova", I see this error:

net::ERR_FILE_NOT_FOUND file:///android_asset/www/index.html was not found

To provide some context... Within git, the Cordova project directory is parallel to the native Android project directory, and there is a git symlink from main/res/assets/www in the native Android project to the www directory in the Cordova project. Furthermore — and I think this is key — the bulk of the Cordova app is pulled down as a bundle from a remote URL. It's the loading of that bundle that triggers Chrome to launch... but I can't figure out why the bundle isn't being loaded into the nested Cordova app as expected.

1 Answers

For me, the problem was a missing symlink to pull the www directory into the assets directory of the native Android app. As a result, the native app was failing to load the embedded Cordova WebView, and the bundle was being loaded straight into Chrome.

I'm on Windows, and the local git repository had core.symlinks = false by default, which overrode my global setting. Once I fixed that issue, the www directory and its contents showed up correctly in my main/res/assets/ directory, and after a rebuild + reinstall the Cordova app loaded correctly.

Related