Tutorial Downloads

File Size
apktool.zip4.32MB

Translations

Know another language? Translate this tutorial!

Removing permissions from CocoonJS compiled APK

Favourite 27 favourites
Tutorial written by HalfgeekOriginally published on 16th, July 2014 - 2 revisions

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:
https://play.google.com/store/apps/details?id=com.halfgeekstudios.starnomad&hl=en

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...

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.

Comments

2
EddyDingDongs 3,457 rep

thanks, that's awesome sauce!

Wednesday, July 16, 2014 at 2:09:17 PM
4
kkletsgo 674 rep

Jesus! (And I am not even religious)

Thank you so much. Now this, this right here is what I call forum/user support.

I mean, I swear, I am left speechless.

Thumbs up man. If you ever swing by Sweden give me a call, the beers are on me :)

Wednesday, July 16, 2014 at 5:22:57 PM
0
Zebbi 11.8k rep

@Silverforce

Is the new Cocoon.io file different? I'm getting this:

Exception in thread "main" brut.androlib.AndrolibException: Could not decode ars
c file
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:55)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibRes
ources.java:315)
at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.jav
a:50)
at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.jav
a:43)
at brut.androlib.Androlib.getResTable(Androlib.java:44)
at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:148)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:98)
at brut.apktool.Main.cmdDecode(Main.java:128)
at brut.apktool.Main.main(Main.java:65)
Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:45)
at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:97
)
at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:82)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:48)
... 8 more

Thursday, June 09, 2016 at 5:59:30 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.