1

I made an application for Android and and I'm trying to make it work on every possible device.

For this, I created different layouts (small, normal, large, xlarge) with different densities (ldpi, mdpi, hdpi, xhdpi), but when I load the emulator with the range of layout-normal-xhdpi, the application doesn't start and make an exit exception (force close). For all other layouts, it works perfectly.

What should it be?

I'm using minSDK = "8", but I tried also with higher APIs and still not working. I also tested with the APIS below level 4 and it works perfectly (the problem of these APIs don't support all resolutions).

tshepang
  • 12,111
  • 21
  • 91
  • 136

3 Answers3

1

You can provide alternative resources (drawables) and layouts (and languages for regional support). Please refer the android developer guide on supporting multiple screens, especially the section on how android selects the resources provided here.

Also an explanation is provided here, just scroll through the page to get a clear view on the subject.

Community
  • 1
  • 1
Gan
  • 1,349
  • 2
  • 10
  • 27
  • I created alternative layouts, but the problem continues. Only for this type of resolutions (640x960, 320 density or 1280x720, 320 density) the application crashes and closes forcefully.. – user1649287 Sep 05 '12 at 15:34
  • I think your problem might lie in the resources that you provide. Make sure all the drawables are provided for the appropriate sizes. Here's an extract form the android site. ** "Caution: If all your resources use a size qualifier that is larger than the current screen, the system will not use them and your application will crash at runtime (for example, if all layout resources are tagged with the xlarge qualifier, but the device is a normal-size screen)."** – Gan Sep 05 '12 at 16:15
  • We have specified in the manifest: anyDensity = "false". I thought if we put that command in the manifest automatically resize the drawables from the folder "drawables" to all the other resolutions (ldpi, mdpi, hdpi, xhdpi). Then we have to put the command in the manifest: anyDensity = "true" and create the necessary folders (drawable-ldpi, drawable-mdpi, drawable-hdpi and drawable-xhdpi)? – user1649287 Sep 05 '12 at 16:46
0

just put these lines of code in your Manifest file :

<supports-screens android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:anyDensity="true" />
Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
  • I have all in "true", and I created layout-small-ldpi, layout-small-hdpi, layout-normal-ldpi, layout-normal-mdpi, layout-normal-hdpi, layout-normal-xhdpi, layout-large-ldpi, layout-large-mdpi, layout-xlarge-ldpi, layout-xlarge-mdpi, layout-xlarge-hdpi.... And all the Layouts works correctly, but when I use the emulator with a resolution and density that belongs to the layout-normal-xhdpi the application closes forcefully... – user1649287 Sep 05 '12 at 14:48
  • @user1649287 what you logCat saying about it. – Piyush Agarwal Sep 05 '12 at 14:54
  • 09-05 15:10:32.421: D/dalvikvm(453): GC_EXTERNAL_ALLOC freed 42K, 53% free 2556K/5379K, external 2730K/3266K, paused 240ms 09-05 15:10:33.112: D/dalvikvm(453): GC_EXTERNAL_ALLOC freed 1K, 53% free 2555K/5379K, external 6449K/8053K, paused 60ms 09-05 15:10:34.231: D/dalvikvm(453): GC_EXTERNAL_ALLOC freed <1K, 53% free 2557K/5379K, external 10167K/13886K, paused 71ms 09-05 15:10:34.821: D/dalvikvm(453): GC_EXTERNAL_ALLOC freed 1K, 53% free 2555K/5379K, external 14817K/16865K, paused 45ms u can see all in http://pastebin.com/jFmFTNsT – user1649287 Sep 05 '12 at 15:13
0

Here are some select lines from your log that tell you what's going on:

09-05 15:10:34.941: E/dalvikvm-heap(453): 9523200-byte external allocation too large for this process.

and:

09-05 15:10:35.112: E/AndroidRuntime(453): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

Your bitmaps are extremely large (one in particular is ~9MB) and you are running out of memory. Use some smaller bitmaps.

kabuko
  • 36,028
  • 10
  • 80
  • 93