[Solved] Android - Game won't open

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
PiFace
Prole
Posts: 28
Joined: Mon Sep 05, 2016 5:35 pm
Location: Brazil

[Solved] Android - Game won't open

Post by PiFace »

I built my app today and I tested on two phones, my friend's phone (a Galaxy Prime Grand Duos, or sth like that) and my own phone (some LG low end phone, I cant remember the model exactly) On his phone it worked just fine, but not on mine, it didnt even open, just a black screen for some moments then it returned to the previous screen. No error messages.

The weird part is that I tested on my phone before the app was usable, just to check if it would run, and it did. Since that time it ran okay, I only added more images (lots of tiny icons) and more lines of my own code. I'm not using any external library. The app is a bunch of images, rectangles, buttons and text, as it is just a helper for an rpg

Some information about my phone:
-it constantly runs out of space (but I managed to get about 200MB to my 40MB app)
-Android Version: 4.1.2

If more details are needed I'll provide them. I'm posting this in a hurry. Any help would be welcome :D
Last edited by PiFace on Sat Jan 14, 2017 2:25 pm, edited 1 time in total.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Android - Gane won't open

Post by Positive07 »

It works on mine

Of course that is a lie, I can't really know if it works because there is no way to tell what you have done or tried... We can't know what is wrong with your game/code because we haven't seen it nor tested it, consider posting a .love/.apk or code snippet of a minimal (non-working) example, otherwise it's impossible to give you any feedback. Sorry I didn't mean to sound rude, it's just that the information you have provided doesn't really provide any valuable information, consider posting more detailed questions so we can give you better feedback
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
PiFace
Prole
Posts: 28
Joined: Mon Sep 05, 2016 5:35 pm
Location: Brazil

Re: Android - Gane won't open

Post by PiFace »

I'm aware I should have posted the love file and/or the apk too, but I wasn't with my pc at that moment. i just posted this before going to sleep, in case this problem was so common that it wouldn't depend on the game, or someone had experienced something similar and had a general answer.

Another weird thing that happened today: I noticed I left the width and height was using to test on the pc on the conf.lua, so I decided to comment out that part, leave only fullscreen, disabled some unnecessary modules (audio, physics and joystick) and rebuilt the apk, installed it, and it opened!... For 5 seconds, then it closed itself again. Sometimes it doesn't close right away, only if I start using it, then it closes after 2 seconds.

Anyway, now I can post the files. (There were some 'Thumbs.db' files on the zip before that, when they were removed, their file size dropped to 20 MB)

Here's the apk:
https://drive.google.com/open?id=0B-dJL ... E83LUdRVFU

And the love file:
digimonRPG.love
(16.19 MiB) Downloaded 140 times
I'm not a good coder, so I'm sure the code is very messy, but I put some comments in there. And if you're a digimon fan, yes, evolution lines and stuff are kinda crazy in that RPG...

As I'm typing this (and while waiting the uploads to finish) I'm getting more and more convinced this is just a memory usage problem, because every time I shrink some images and build the apk again, I can make the app run for a little more time (last time I tried, I could even reach all screens available, but after pressing some buttons, it closed again and I couldn't do the same thing again)



EDIT: Btw, I forgot to turn on the correct dimensions for the screen in the conf.lua. You should uncomment them, so it doesn't get stretched into a widescreen monitor :P
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Android - Gane won't open

Post by raidho36 »

In the love.load you load all of your graphics. Your main logo file is 3-something megabytes; each of the 360x480 cards + 64x64 thumbnails is 0.5 megabytes (there are 140 of them = 70 megabytes) and your two seals files are 5 megabytes each and therefore 10 megabytes together. Graphics alone is would be responsible for 83 megabytes of memory consumption. The framework itself also has some overhead, about 30 megabytes. If you only have 200 megabytes tops to spare and even then it runs out all the time, it's no wonder it fails to work.

It opens up on my phone (1 gig free) but it takes a while, and memory consumption reports 149 cached 219 megabytes for this app.
User avatar
PiFace
Prole
Posts: 28
Joined: Mon Sep 05, 2016 5:35 pm
Location: Brazil

Re: Android - Gane won't open

Post by PiFace »

How can I know the true amount of bytes that images will use, and what are the best ways to reduce that amount specifically? For example, the seal file is 100 KB, and all the cards together take up ~6 MB, but they obviously take up more memory than that while the app is running, as you said, it uses 150 MB. Also, is there any tip to reduce the usage of the framework?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Android - Gane won't open

Post by raidho36 »

You can simply calculate. LÖVE uses 32 bit textures, so that's W×H×4 bytes.

To reduce amount of memory you need to have less pixels loaded at a time. Shrinking graphics will get you the quickly - halving resolution quarters number of pixels. But you probably want to simply keep unused graphics out of memory - only load it if you're going to use it and once you don't need that image displayed anymore remove it from memory.
User avatar
PiFace
Prole
Posts: 28
Joined: Mon Sep 05, 2016 5:35 pm
Location: Brazil

Re: Android - Gane won't open

Post by PiFace »

Ok thank you! You're always saving my life lol

Once I change the way graphics are handled, I'll give feedback.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Android - Gane won't open

Post by Positive07 »

You should also use [wiki]CompressedImageFormat[/wiki]s for mobile, they stay compressed in memory.

Also consider reducing the quantity of assets, using a spritesheet , they consume less memory than multiple sprites and allows you to use [wiki]SpriteBatches [/wiki] which helps speeding up drawing.

Consider disabling some unused [wiki]love[wiki] modules at compile time when creating the APK, such as Physics or Audio

[wiki]love.lowmemory[/wiki] is called when you are running out of memory, you can garbagecollect all your images and display a nice error message to the user of your app.

Also if you can optimize your code you may be able to load images only when they are needed, for example if you need an asset when in combat mode then load that asset when entering the combat mode, it may take some time so you can put a nice transition or loading screen, when going out of the combat mode you nill it and [manual]collectgarbage[/manual]
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Android - Gane won't open

Post by raidho36 »

Note that compressed GPU formats must be "pre-compressed", you can't load a PNG file and get a DXT compressed texture.

Atlases speed up rendering due to reducing number of draw calls -it saves on texture switch calls- but I reckon it doesn't save any memory, in fact it could be wasteful due to blank pixels and impossibility to unload individual sprites.
User avatar
PiFace
Prole
Posts: 28
Joined: Mon Sep 05, 2016 5:35 pm
Location: Brazil

Re: Android - Gane won't open

Post by PiFace »

Wow, just making graphics load only on demand, then releasing them when no longer used made everything work! Thank you so much guys
btw, I'll add a solved tag to the topic (lol I mistyped game in the title)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests