caiobiodere / cordova-template-framework7-vue-webpack

Framework7 - Vue - Webpack Cordova Template with Webpack Dev Server and Hot Module Replacement
Apache License 2.0
621 stars 154 forks source link

"cordova.js" was not generated in Android #108

Closed caiotarifa closed 6 years ago

caiotarifa commented 6 years ago

Hi.

I am getting this error and my application is not running.

CordovaDeviceRouter.js:14 GET http://10.0.1.17:8081/platform_cordova_files/android/cordova.js net::ERR_ABORTED
[Vue warn]: Error in mounted hook: "ReferenceError: cordova is not defined"
Refused to execute script from 'http://10.0.1.17:8081/platform_cordova_files/android/cordova.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Has anyone had a similar problem?

caiobiodere commented 6 years ago

Did you check if you have Cordova installed on your machine?

Cordova: https://cordova.apache.org/

caiotarifa commented 6 years ago

Yes, @caiobiodere.

$ cordova -v
8.0.0

This error is in Chrome inspector, after I compiled my app w/ cordova run android -- --lr.

captura de tela 2018-04-11 as 16 06 09

Thanks

caiotarifa commented 6 years ago

@caiobiodere, I realized that the cordova.js file was not generated on Android, even using cordova run android -- --lr command.

Can you tell me why?

captura de tela 2018-04-11 as 16 17 45 captura de tela 2018-04-11 as 16 18 00

caiobiodere commented 6 years ago

Could you check your npm, node and cordova versions?

Please start a new project from scratch using cordova: cordova create <project_create_dir> [com.example.projectname] [ProjectClassName] --template cordova-template-framework7-vue-webpack

Npm version: 5.6.0 Node version: 8.9.4 Cordova version: 8.0.0 cordova-android version: 7.0.0 cordova-browser version: 5.0.3

37040768-5d0c7e06-2139-11e8-8540-ac89ac8121c1
caiotarifa commented 6 years ago

Does testing on a remote device and not the emulator might be the cause of the problem?

$ cordova -v
8.0.0

$ node -v
v9.5.0

$ npm -v
5.6.0

The cordova-android version is 7.0.0.

I will try to create a new project from scratch soon.

caiobiodere commented 6 years ago

Yes mate, that's really the cause of your problem and there has been explained in another task : https://github.com/caiobiodere/cordova-template-framework7-vue-webpack/issues/62. Could you use with the native emulator?

caiotarifa commented 6 years ago

Got it.

On remote iOS it works without problems. It is an Android thing.

caiobiodere commented 6 years ago

I will check your problem when I get some time for free, Just to I know are you using this command to test on other devices?

cordova run browser -- --lr

caiotarifa commented 6 years ago

No, I am using cordova run android -- -lr to test on Android and cordova run ios -- -lr to test on iOS.

Ok! Thank you, xarΓ‘. πŸ‘

caiobiodere commented 6 years ago

Yes I know what you doing there, but please don't use android or ios platforms on browsers that's not a good situation and probably is going to take some errors, always is better using (run browser) for browsers

I appreciate your concern, awesome Xara πŸ‘

caiotarifa commented 6 years ago

@caiobiodere, sure... I didn't use the browser (just to check if the file cordova.js exists on the local server).

In fact, my app doesn't work in browsers.

nuxcasino commented 6 years ago

when I first time run cordova.js loaded after than cordova.js not found

catalsdevelop commented 6 years ago

@caiotarifa I think that's because of hooks problems. see https://github.com/caiobiodere/cordova-template-framework7-vue-webpack/blob/master/template_src/hooks/beforedep.js#L14. In cordova-android@7.1.0, there is no assets/www in android dir, so I change it to platform_www, and run cordova run android -- --device --lr, everything is ok. But I didn't dig too much about beforedep.js. Can u take a look at this problem? @caiobiodere .

my env:

npm 5.6.0
node 8.9.4
cordova-cli 7.1.0
cordova-android 7.1.0
cordova-browser 5.0.3
cordova-ios 4.5.4
caiobiodere commented 6 years ago

yes @catalsdevelop I'm going to see that

hastom commented 6 years ago

Got a similar problem as I was building app with webpack to www/dist. In my index.html including cordova.js like this ../cordova.js fixed an issue for me

tartinesKiller commented 6 years ago

@catalsdevelop fix seems to work for me too (thanks a lot!), it seems like a path confusion?

caiobiodere commented 6 years ago

@catalsdevelop @hastom @tartinesKiller Thank you guys, everything is working now πŸ‘