poetic/ember-cli-cordova

Scripts/Resources not loaded on Android device.

Closed this issue · 2 comments

While my application runs just fine in my desktop browser, it fails to run on my android device. Using Chrome/Inspect I was able to find out why:

file:///ember-cli-live-reload.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///assets/vendor.css Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///assets/community.css Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///assets/vendor.js Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///assets/community.js Failed to load resource: net::ERR_FILE_NOT_FOUND

Since I made no changes to the environment or any configuration of cordova, I wonder why this happens. The APK contains all these files. Guess its the leading slash since this would point to the root but the assets are stored in www I think.

So is it my failure? The script tags are generated by ember-cli/cordova so I don't know how to debug this.

Well, the solution is pretty simple.
The problem was, that I used:

EMBER_CLI_CORDOVA=0 ember serve

For local development. Since that made the environment variable persistent, the cordova library was excluded from the generated app/apk.

So setting

EMBER_CLI_CORDOVA=1

before the cordova build fixed the issue.

Wouldn't it be nice to have a flag for ember serve?

dukex commented

you can create a alias like:

ember_build_cordova="EMBER_CLI_CORDOVA=1 ember cordova:build" 

I dont know who this addon will know when the user is running server or not, and sometimes (livereload for example) we need the cordova.js on server