Use Cordova to compile HTML5 games to Android App

Install npm and cordova

https://docs.npmjs.com/downloading-and-installing-node-js-and-npm

It is also useful to insall nvm which is node version manager to manage different versions of node.js.

For windows the installable can be downloaded from here

https://github.com/coreybutler/nvm-windows/releases

check version of node, npm and, cordova using the commands as following

node -v
npm -v
cordova -v

Once nvm is installed it can be used to check for installed version of node by using the command

nvm ls

On windows use following command to see available versions on node

nvm ls available

If a higher version of node is available it can be installed by specifying the version as following

nvm install 17.4.0

Configure the system to use the installed version of node now

nvm use 17.4.0

Cordova install and update

-- fresh install --
npm install -g cordova

-- uninstall and install --
npm uninstall -g cordova
npm install -g cordova@10.0.0

-- update to latest version --
npm update -g cordova

Update npm to the latest version by specifying the version number

npm install -g npm@8.4.0

All of the above commands are specified to make sure that we have latest version of node, npm, nvm, cordova installed before we start creating packages for our HTML5 game. Version numbers are mentioned in the command as of the date this article was written. Make sure to check the latest version of all tools and change the version numbers accordingly.

Open Node.js command prompt and run commands to create our app. Go to the folder where you would be creating the app.

cordova create myApp com.myCompany.myApp myApp
cd myApp
cordova plugin add cordova-plugin-camera --save
cordova platform add android --save
cordova requirements android
cordova build android --verbose
cordova run android


Leave A Comment

Your email address will not be published.