Empty cocos2D-x project is too big - cocos2d-x

I want to create a very small (in apk size) Android game, I hope is not more than 3mb, so anyone with low avaiable space in the phone can play it.
I can do it with libgdx but I want to use cocos2d-x.
The problem is that I built the start template project that only has the cocos logo image, using Android Studio in release mode and the APK built is 3.2Mb. Is too big. I run the analysis and the .so file size is 2.4mb.
I'm missing some optimizations or something? I'm new in cocos2d-x so maybe there is something I don't know.

Here are the things you can try:
Comment out physics engine, particle engine, any 3D libraries and other unused file formats from CCConfig.h
Check if you are loading any TTF fonts (they can take around 600kb each)
Build only for 1 arch at a time (not arm and x86 mixed)
If you do all that you can probably get down to around 1mb theoreticaly.

Related

Library assets not compiling when publishing for AIR

Yesterday I started messing around with Adobe Scout. It gave me a message that said that my function times are not accurate because I'm running a debug mode (in a file that is compiling as an AIR app) and to try compiling a published version first. Thus began my foray into the exciting world of AIR certificates and Windows Installer packages. I made certificate, published it, opened the published package, installed it, opened the resulting file, and found... fanfare ... a rectangle object I draw with AS3 and nothing else. When I test the movie (debug version) in AIR, it has the rectangle as well as a 20x20 map of tiles that are created at runtime from a bitmap that is blitted into 16x16 tiles.
Huh? Do I need to do something special when publishing for AIR to embed the library item? Anyone have this issue publishing to AIR where library assets are unavailable at runtime?
Of course I'll post code if anyone thinks they would like to see it, but it all works fine in flash player, fine (albeit slow) in Adobe AIR for Desktop (when testing), just missing library assets when published and installed via Windows installer.
update
for that matter, when I publish a swf for playback on the web or flash player, a similar thing: just a colored background (per my .fla file settings) but no rectangle and no blitted bmp tiles. Could I be executing code before something is loaded, and when it is in a debug mode, the setup takes longer, so things have time to get loaded before trying to execute? I've tried to avoid this, but maybe failed?
So, apparently making an .exe file or AIR app doesn't stand alone from the library components. Their is probably a way to embed them in the project, but for my purposes, I found that just making sure that the .exe and necessary .png files are in the same source file solved the issue. The problem was that my .exe file was automatically getting compiled and saved into a different folder, so I thought that folder must have all the needed files in it.
So, the bottom line is just that an .exe or AIR file, when published, won't automatically have the needed files in the right places. It still needs to point to the correct file location for those files.

Optimizing size of the apk file

I am currently working on a mini game using libgdx 1.0 + box2d with no more than 4 screens.
My base virtual screen resolution is 854x480 and texturepacker i being used.
The apk file after compiled has about 2.2mb. After a closer look, I just noticed that there 3 folders in the lib folder with the "same" files totaling 1.2mb:
android
lib
armeabi
libgdx.so
libgdx-box2d.so
armeabi-v7a
libgdx.so
libgdx-box2d.so
x86
libgdx.so
libgdx-box2d.so
Well, I need the files libgdx.so and libgdx-box2d.so, but is it safe to get rid off some of them or they are there to support different target devices?
They are not the same files.. check their sizes.Every version is for a different platform and its not really safe to remove any of them.
armeabi: compatible with all the devices,kinda like a compatibility mode ,much slower cause does not offer platform specific optimizations.
armeabi v7a:offers hardware float operations and other things that improve performance.
x86:same as v7a but for x86 architectures.
Most of the devices will probably be able to run on just armeabi but much slower than on v7a or X86.

Using XNA content pipeline with SharpDX game for Windows Phone 8

I've decided to try out SharpDX for my first Windows Phone game but I'm having troubles setting up Content Pipeline working.
I have tried creating an XNA Content Project and dummy XNA Game Library project (just to reference Content project from) but I've got SharpDX.Toolkit.Content.AssetNotFoundException when I tried to load a texture.
Second try was to use XNA 4.0 Content Compiler to get .xnb file and add it manually to my project but again I've got AssetNotFoundException.
The Content.RootDirectory is set to correct value ("Content", the name of an XNA Content Project in first try, and a name of folder containing .xnb file in second try), so that's probably not an issue.
So, the real question is, how to load a Texture2D from file in SharpDX project?
SharpDX Toolkit is not a XNA compatible API/implementation, and thus, is not able to load XNA content. It is a high level API for Direct3D11, with some XNA like interfaces/features (SpriteBatch, BasicEffect, ContentManager...etc.) but not binary compatible with XNA. If you want to work with legacy XNA projects, you will have to use a library like MonoGame
Have you tried to create Windows Phone 8 project using MonoGame project template? MonoGame make it a lot easier to create XNA game on WP8 (it uses SharpDX under the cover). You can download the latest framework from here: http://monogame.codeplex.com/releases/view/102870

Flash Builder: Mobile AS3 Project or Mobile Flex Project?

This month I started to play with Flash Builder because I don't have a mac to create native iPhone apps.
I have made a Flex Mobile Project and an AS3 Mobile project. Both do mostly exact the same and I see great differences in operation speed (AS3 version is much faster). Also the size of the AS3 version is less than the size of the Flex version when I deploy the project.
But one thing disappoints me, the size of a deployed AS3 app (Android) is still about 8MB. I think that is quite huge for a simple app, or is it normal? I did not test the iOS version because I am not an Apple Developer member (is there a trick to deploy an iOS app with fake certificates)?
Resources I have used in the apps:
Two images approx. 35kb in size
A StageWebView
I want to know:
What is the average size of a simple app when it is a native app (apk file)?
What is the difference between an AS3 app and a Flex app except the libraries that re used?
Is the AS3 app converted to C or another language?
Why is the apk so huge (IMO)?
Is there a trick to deploy an iOS app with fake certificates? (just for testing)
Thanks for the answer(s).
What is the average size of a simple app when it is native app (apk file)?
I have no idea. When you were comparing sizes; did you export a release build or a debug version? The full version of my app; using Captive Runtime is 12MB. That includes all the embedded images. I thought that roughly 8MB is the size of the embedded runtime. Of course, if you don't use Captive Runtime then the app will be smaller; but it will have a depency on the user having the runtime installed.
What is the difference between an AS3 app and a Flex app except the libraries that are used?
For all intents and purposes nothing. The Flex Framework will need to execute code to setup the framework and such. In theory this 'impact' is offset by the value that the framework brings.
- Is the AS3 app converted to C or other language?
Not for Android or Playbook. It relies on the Mobile AIR Runtime--which I assume is written as a native app somehow. For iOS there is a more in depth conversion taking place; but no on knows the exact magic sauce; but it the process is much more intensive than Android or Playbook and people believe that your code and the AIR Runtime is converted to Objective C somehow in a way that is not in violation of the Apple licensing agreement.
Why is the apk so huge (IMO)?
Huge is open to interpretation. Without seeing your full app code; it's tough to judge.
Is there a trick to deploy an iOS app with fake certificates? (just for testing)
I don't think so; although there may be possibilities on unlocked devices.
You would like to use Mobile AS3 Project if you want you apps to be smaller and your GUI mainly contains vector graphics and Mobile Flex Project if you prefer to use standart GUI Controls that comes together with Flex framework but adds overhead in size because of controls that come with it.
As of the other questions:
the size of the apps is different on mobile platforms. Typical iOS app is about 2MB - 20MB. It really depends on resources you store with your app. What might be important to you is not to overcome 20MB if not needed because 20MB+ apps require Wi-Fi connection to be downloaded.
(However you should export release build version only as mentioned by www.Flextras.com)
there is no fundamental difference between AS3 and Flex apps - they both compile to the same instructions that executes on targeted mobile platform.
as far as I know (being iOS developer myself) there is no workaround to deploy an iOS apps. You need to use Mac and become Apple Developer to deploy with valid certificate.
to make your app smaller try to pai special attention to the resources you add to the project. Although I believe the size is so big because of framework itself, you would like to use more vector graphics vs. bitmaps when compiling apps with Flash/Flex.
When you export for Android you have an option of embedding the air framework in the application, that way your users don't have to download air. you can export your application without air embed which will result in a much lighter application, however your users will need to download air runtime. http://cookbooks.adobe.com/post_How_do_I_create_an_AIR_application_for_Android_tha-19299.html

Best way to make a downloadable version of a Flash game?

I already made a game with flash, and I want to provide an easy download for people that would rather play offline. Thing is, i use a folder whole structure to dynamically load content per level. Folder structure looks like this, not that it matters that much:
Game folder
animations
anim1.swf
anim2.swf
sounds
music1.mp3
soundeffect1.mp3
levels
level1.lev
level2.lev
myGame.swf
How should I go to distribute this? Should I just resort to make a zip file for the flash game and assume people know how to extract and open the swf? Is there any other way to port easily as an executable? Perhaps Adobe Air (not sure if this works though)?
Thanks, and please help!
Distributing a zip file is the only option if you really want that structure to prevail. Else,
Embed all the resources in the main (myGame) swf & distribute it.
Provide a html page for people who do not have standalone flash player installed.
Embedding as a single file allows the browser to cache the single swf & allow the player to keep playing offline until cache is cleared. So user might not even need an explicit download.
If you are using Flash Builder it is fairly straightforward to compile the application into a self-installing AIR executable (or DMG on a Mac). It is possible to include the AIR runtime which would avoid potential problems of the user not having the correct flash player for example.
An alternative to AIR would be to create a projector executable from inside the standalone Flash Player or from the Flash authoring environment.
Another option to using a zip file would be to use a free installer creator such as InnoSetup or Nullsoft on Windows, or Packager on Mac. Linux users are generally more tech savvy and so a tar would probably be well understood.
Adobe AIR works wonderfully! I use it for my own project, and your project should transition over to it with little to no modification (any issues should show up in the Compiler Errors and Output). The only downside is that, past AIR 2, there isn't any Linux support.
The other option is obviously to create a standalone .SWF projector inside a zip or installer, but in my opinion, that isn't the sleekest way to deploy for desktop. The advantage of AIR over this is that it gives you access to additional desktop functions that Flash Player doesn't.