Author Topic: JPCT errors while trying to run app on Android Ice Cream 4.x  (Read 9267 times)

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
JPCT errors while trying to run app on Android Ice Cream 4.x
« on: January 09, 2012, 09:24:47 pm »
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.


Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #1 on: January 09, 2012, 10:01:26 pm »
texture size must be power of 2, ideal is square... 8, 16, 32, 64, 128, 256, 512, 1024, 2048

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #2 on: January 09, 2012, 10:08:02 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #3 on: January 09, 2012, 10:21:27 pm »
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.
« Last Edit: January 09, 2012, 10:32:53 pm by EgonOlsen »

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #4 on: January 09, 2012, 10:27:49 pm »
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.

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #5 on: January 10, 2012, 02:07:28 am »
Try placing your image files in res\drawable-nodpi to avoid resizing and downsize the 768x768 image to 512x512 to keep the GPU happy.

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #6 on: January 10, 2012, 03:32:33 am »
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.

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #7 on: January 10, 2012, 03:57:34 am »
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.

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #8 on: January 10, 2012, 04:13:25 am »
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

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #9 on: January 10, 2012, 04:18:56 am »
Forgot about the drawable folder, the images will also be resized if in that folder.

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #10 on: January 10, 2012, 04:33:41 am »
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


Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #11 on: January 10, 2012, 05:19:43 am »
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.

Code: [Select]
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

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #12 on: January 10, 2012, 07:29:43 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #13 on: January 10, 2012, 09:32:03 am »

Offline icarusfactor

  • int
  • **
  • Posts: 58
    • View Profile
Re: JPCT errors while trying to run app on Android Ice Cream 4.x
« Reply #14 on: January 10, 2012, 03:31:30 pm »
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.