JPCT errors while trying to run app on Android Ice Cream 4.x

Started by icarusfactor, January 09, 2012, 09:24:47 PM

Previous topic - Next topic

icarusfactor

I could not get my Android 2.2 JPCT code to work on Android 4.0. I updated the build and that let me compile, but get errors on texture size now when I try to run the app.

-----------------adb logcat errors-------------------
I/jPCT-AE ( 4921): Loading Texture...
I/jPCT-AE ( 4921): [ 1326139632424 ] - ERROR: Unsupported Texture width: 768
I/jPCT-AE ( 4921): [ 1326139632427 ] - ERROR: java.lang.RuntimeException: [ 1326139632424 ] - ERROR: Unsupported Texture width: 768
-----------------------------------------------------------
I had compiled it under target 7 and 1 - 1 being 2.3 based stuff and 7 being 4.0 apis with same results.


Thomas.

texture size must be power of 2, ideal is square... 8, 16, 32, 64, 128, 256, 512, 1024, 2048

icarusfactor

That is wild, this compiles under 2.2 Froyo just fine and it is a power of 128, 768 should be ok and is square just 768. It worked because I based my app base size on this and had been working fine until I upgraded.

EgonOlsen

768 isn't a power of two. Depending on where you store your textures (for example in drawable, which i don't recommend), the OS might have scaled them on 2.2.

icarusfactor

I am using a new android SDK so that may be the case how it compiled in the images from resources. Will try that later and see , thanks.

K24A3

Try placing your image files in res\drawable-nodpi to avoid resizing and downsize the 768x768 image to 512x512 to keep the GPU happy.

icarusfactor

Finally getting chance to look at the images and my background image has the size is 1024 x 1024 not 768x768 , all other images are 512 x 512 or smaller , so I don't even have any 768 width files.  Now I am even more confused nor do I set 768 for any temp buffers in my app source.

K24A3

What res folder are the images placed in?

If they are in drawable-hdpi, drawable-mdpi, or drawable-ldpi, there is a good chance that they are being resized automatically to match the DPI of the screen.

Create a folder called drawable-nodpi, move the images in there, then clean and refresh the project.

icarusfactor

All my images are placed in /res/drawable  only the icon is in each of the other directories. Will try renaming the directory to /res/drawable-nodpi

K24A3

Forgot about the drawable folder, the images will also be resized if in that folder.

icarusfactor

Thanks , I renamed the folder to a -nodpi and it got past that error but I am now plagued with another error . I don't get this error under the 2.2 just wondering how I get around this or get ICS to release more mem for my app.

E/AndroidRuntime( 2582): java.lang.OutOfMemoryError


K24A3

Something must be using too much memory. If you are allocating large arrays, null them after usage so the garbage collector frees them.

Use the below function at various areas during initialization to see how the RAM accumulates. For example, call logMem() before loading all the textures, and then after they are loaded.


public void logMem()
{
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(0);
        df.setMinimumFractionDigits(0);

        String sRAMString = "RAM allocated: " + df.format(new Double(Runtime.getRuntime().totalMemory()/1048576)) + "MB of " + df.format(new Double(Runtime.getRuntime().maxMemory()/1048576))+ "MB (" + df.format(new Double(Runtime.getRuntime().freeMemory()/1048576)) +"MB free)";
        Log.v(TAG, sRAMString);
}


1024x1024 textures use a big chunk of memory when loading them so think about decreasing the size to 512x512

icarusfactor

Thanks all , I think I need to do a redesign of it to clear up the out of memory problem, this was my first try making an app and it worked but just kind of went along as I learned stuff. Will make a plan so it will scale for X amount of objects.


icarusfactor

I was thinking of using a database for re-factoring the memory footprint down. I did not know how Android did DB's when I started so I kept "ALL" static and dynamic data in memory.  Will plan to move all the static to DB and to try to move as much dynamic data I don't need instantly as well.

Now knowing how Android uses SQLite is still a pain , but now that I have "rooted" my Tablet will be much easier to debug and manage DB errors.