I made the port in less than five minutes without installing any software or SDK by compiling it directly on the cloud thanks to Cocoon.io which provides all the tools and services to build awesome native HTML5 apps and games with a simple workflow and all the power of Cordova.
Now it’s time to write a step by step guide about this process.
1 – Obfuscate your code
2 – Create your Cocoon.io account
Go to Cocoon.io, and choose your plan. I am using the free plan which allows to completely manage up to two projects simultaneously with plugins, with a 50MB max project size, which can be raised to 250MB – with 10 projects simultaneously – for as low as $8/month, which is the plan I recommend to start with.
3 – Include cordova.js file
Go to the official GitHub repository and grab the latest version. Then include it in your project, making your
index.html page look something like this:
<meta name = "viewport" content = "width = device-width, initial-scale = 1.0, maximum-scale = 1.0, minimum-scale = 1.0, user-scalable = 0, minimal-ui" />
<link rel = "shortcut icon" sizes = "256x256" href = "icon-256.png" />
<style type = "text/css">
<script src = "game.js"></script>
This will allow you to use Cordova specific features, like…
4 – Add a deviceready event to start the game
Unlike old CocoonJS plugins, Cocoon Canvas+ plugins need to wait for Cordova deviceready event to start working. This event fires when Cordova is fully loaded, so your game will be executed this way:
document.addEventListener("deviceready", onDeviceReady, false);
// your game here
Now you are ready to make your game be processed by Cocoon.io
5 – Zip your HTML5 game, THE RIGHT WAY
Your project won’t work if you zip your project with don’t use the Windows compression, use WinRAR instead, just create a Zip file.
If you have a Mac, you can use your default macOS zip utility.
6 – Download Java JDK
You will need it to create your keystores, required by Cocoon.io to compile your game. You can download it from this page.
7 – Create your keystores
You are going to use keytool to generate your release or debug keystore.
Execute the command prompt as administrator, move into your
bin directory into your
Java/jdk directory then write
keytool -genkey -v -keystore my-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
for your release keystore, or
keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
for your debug keystore.
8 – Compile signing section
At this time you are readyto upload the keystore along with its passwords
Now, you can compile your Android native app, directly on Cocoon cloud