Removing permissions from CocoonJS compiled APK

1

Attached Files

The following files have been attached to this tutorial:

.zip

Stats

3,313 visits, 5,349 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 16 Jul, 2014. Last updated 19 Feb, 2019

Straight to the point: Lots of intrusive permissions are looked down upon by a lot of gamers on Android and many of them will refuse to even install your game to try it out if they see a huge list of required permissions.

Until Ludei implement an optional permissions on their cloud compiler, we have to do a bit of "hacking" to fix the problem ourselves.

Get the attached apktool.zip, extract it to a folder C:\Android (to make it easier later).

Copy your release CJS compiled game.apk (from herein, referring to that APK file as game.apk) into C:\Android so its in the same folder as the extracted apktool files.

Open command prompt in C:\Android by right clicking somewhere in that folder while holding SHIFT key.

First, we need to install the framework of our CJS compiled game.apk, type this in:

apktool if game.apk

Its instant, with a feedback that it installed in location 127 or thereabouts. Now we have to decompile the APK, type this in:

apktool d game.apk game

It take awhile depending the size of your game & speed of your PC, but all the contents of your game.apk will be decompiled and stored in a subfolder with the same name as your game.apk, ie. game. Note, if you use different versions of apktool, you may need to change the flag to: apktool d game.apk -o game so it decompiles properly.

Browse the new game subfolder, you will see all the contents. What we are after is the AndroidManifest.xml, open it with Notepad++ (Highly recommended! Download it on CNET), you will see something like this:

Hi-res version: halfgeekstudios.files.wordpress.com/2014/07/androidmanifest.jpg

Remove the permissions by deleting the grey highlighted lines!

The permissions ACCESS_NETWORK_STATE & INTERNET are required, if you remove it, your game is likely to crash on startup. This is true even if you have no Ads or IAPs or Social plugins. CJS needs these since its got some built in analytics that require it. BILLING is also required if you implement IAPs. Interestingly, Google has decided that these three aforementioned permissions will now be considered normal and they do not warn users when games have these three only, only if it contains the other permissions!

Here, I'd like to point out this line:

<supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />

You can edit your game to be on phones or tablets by setting them to false. If you set smallScreens & normalScreens ="false", the game is only compatible with tablets or vice versa (I've tested this with my own games). This is handy if you design your target to tablets and don't want to manually filter over 6,400 devices, one at a time. :D

Once the changes are done, save it. Go back to the command prompt, type this in to recompile it into a new APK:

apktool b game game_new.apk

Takes awhile, but you will get your game_new.apk that is modified. Now you need to proceed with normal signing and zip aligning prior to uploading to Google Play.

My example CJS compiled game on Google Play that's been through this process:

play.google.com/store/apps/details

Note that CJS up to version 2.0.1 has a nasty v8 javascript bug that makes it crash on a lot of Samsung & some other devices, even the new ones. Oh well, can't fix everything! Le sigh...

.ZIP
  • 0 Comments

Want to leave a comment? Login or Register an account!