androidpermissionsapkcocoonjs

Ludei Android App requires unnecessary permissions


I use construct 2 to build my apps and then I export them to CocoonJS which then compiles them as a native app. I download an unsigned .apk file, sign it then upload it Google Play. The apps work great, just like they were natively written.

When I compile my app with CocoonJS it requires all of these permissions that my app doesn't need. How can I remove the unneeded permissions?


Solution

  • 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). https://static3.scirra.net/uploads/articles/1071/apktool.zip

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

    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:

    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.

    https://www.scirra.com/tutorials/1071/removing-permissions-from-cocoonjs-compiled-apk