Using LogCat to understand crashes

Discussion in 'Tutorials' started by Vas, Sep 6, 2013.

  1. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500


    Look at these lines:
    at com.sbg.lwc.SBLiveWallpaper$LwpEngine.draw(SBLiveWallpaper.java:879)
    at com.sbg.lwc.SBLiveWallpaper$LwpEngine.drawFrame(SBLiveWallpaper.java:726)
    at com.sbg.lwc.SBLiveWallpaper$LwpEngine.onVisibilityChanged(SBLiveWallpaper.java:630)

    Go to SBLiveWallpaper.java in your project that's reporting these errors, and examine the lines 879, 726 and 630
  2. Joshua Seasoned Vet

    Member Since:
    Jul 12, 2013
    Message Count:
    116
    Likes Received:
    16
    Trophy Points:
    100
    Vas, this happens even when I don't run the live wallpaper through eclipse =/ it's weird.
  3. stas New Guy

    Member Since:
    May 28, 2013
    Message Count:
    9
    Likes Received:
    3
    Trophy Points:
    0
    Hi,Joshua!
    I also had the same problem! In order to get rid of her, I changed the resolution backgrounds. example: SBLiveWallpaper.java changed lines
    PointF hSize = new PointF (1080, 960);
    PointF mSize = new PointF (640, 480);
    to
    PointF hSize = new PointF (1060, 940);
    PointF mSize = new PointF (620, 460);
    and in Photoshop changed the resolution backgrounds: 1080x960 to 1060x940 and 640x480 to 620x460.
    and this error became popping up on a lot less.
    Joshua likes this.
  4. Ramjet Active Member

    Member Since:
    Dec 2, 2013
    Message Count:
    67
    Likes Received:
    12
    Trophy Points:
    50
    Guys, try this...

    I don't have much knowledge of bitmap re-cycling, but my understanding is that the error's caused by android trying to render a view with a bitmap, but the bitmap has already been re-cycled for garbage collection. If you haven't changed any code in your activity, then I'd dare to suggest it might be a little bug in the source code and how the methods handle garbage collection. (although I haven't run it in DDMS to pinpoint it, so it could be caused by anything).

    A dirty fix, that might or might not work in every situation, but definitely works in borderline cases, is to make the garbage heap bigger so it takes longer to be collected.

    So, in the package pane in eclipse (on the left, hopefully), right click your project, go to Properties, select "Android" on the left, and in the "Project Build Target", crank the level up as high as you can, like "Android 4.4.2 api level 19" (it won't hurt the project, there's a whole bunch of deprecated code already in it ;) ) If you only have api10 then use the Android SDK manager to update!

    btw, setting the build level to api 19 (or 18 or 17 etc), won't prevent users of older devices from using the app, the minimum SDK level remains the same in the androidmanifest.xml ...just in case you wondered...

    Now in the androidmanifest.xml in the application tag, add:

    android:largeHeap="true"

    So you have something like:

    <application
    android:label="@string/appName"
    android:icon="@drawable/ic_launcher"
    android:allowBackup="false"
    android:largeHeap="true" >

    Hopefully, that should help a bit...

    PS, the most obvious cause though, would be images that are too large (mb, not px). If you use png's, try https://tinypng.com/ to shrink your images file size without losing quality.
  5. fatos LWC Major

    Member Since:
    Apr 2, 2013
    Message Count:
    268
    Likes Received:
    73
    Trophy Points:
    200
    I don't know Vas,something...teach us for e.x a group of items to move just in the bottom and another group of item to move just in the middle
  6. Vas Origin

    Member Since:
    Jan 4, 2012
    Message Count:
    770
    Likes Received:
    175
    Trophy Points:
    500
    I have an idea for a very simple tutorial. It will help you understand your users' behaviour.
    I will post it tomorrow :)
    fatos likes this.
  7. fatos LWC Major

    Member Since:
    Apr 2, 2013
    Message Count:
    268
    Likes Received:
    73
    Trophy Points:
    200
    Thanks Vas...I will be waiting :)

Share This Page