Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: [Tutorial] How to get a Logcat -example - check for Battery drain

  1. [translate]    #1
    Moderator
    Join Date
    May 2010
    Location
    h3LL
    Posts
    3,498

    Thumbs up [Tutorial] How to get a Logcat -example - check for Battery drain

    Well I always read on the forum about logcat, and being in the computer field I knew it was about getting logs or system activity, thought it was a very difficult thing to do and then I read about it and realized it is so simple.


    In the below explanation I will show you an app which is running even when it should not and hence draining the battery.

    So, here we go.

    What is logcat?

    Logcat is the command to view the internal logs of the Android system. Viewing logs is often the best way to diagnose a problem, and is required for many issues. This way you'll find out what apps are doing in the background without you noticing.

    Advantages of Logcat


    • Debugging
    • You can see what processes are running, if a process is running after a certain interval of time, it will eat battery. So you can also find out what is draining your battery.



    How do I install it?


    1. Make sure you've enabled on USB debugging on your phone in Settings -> Application -> Development
    2. 2. Get the Android SDK here: Android SDK | Android Developers
    3. Extract the SDK to any folder say C:\Android
    4. Make sure that you have installed the drivers for your phone and the operating system recognizes your phone.

    Everything installed? Continuing...

    Now how to actually access the log, everything in italic are commands you need to enter.


    1. Open the 'run' dialog by pressing the 'Windows' + 'r' buttons on your keyboard (minimize the browser & other non-windows programs)
    2. cmd (this will open a DOS prompt)
    3. cd c:\Android\tools (go to the directory where you extracted the SDK)
    4. adb shell
    5. Now you'll see just a '$'
    6. logcat


    You can now just press the power button on your phone to see what happens. It displays everything the device is doing.

    So the thing is: leave your device connected for a while and see what is actually going on when you're not using it.

    An Example


    Twidroid auto refreshing my Tweets

    Code:
    => again nothing special  
    D/dalvikvm(   75): GC freed 40165 objects / 1974768 bytes in 91ms 
    D/dalvikvm( 1560): GC freed 25 objects / 1800 bytes in 53ms 
    D/dalvikvm( 1687): GC freed 7551 objects / 330032 bytes in 102ms   
    
    => Twidroid doing it's thing  
    
    I/ActivityManager(   75): Start proc com.twidroidpro:remote for service com.twidroid ...
    
       => back to freeing up the objects  
    
    D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 95ms 
    D/dalvikvm( 1253): GC freed 281 objects / 12688 bytes in 91ms
    If you're seeing apps that are constantly busy when they shouldn't that means they're draining battery because of bugs in the app/ bad coding/ ...

    Example of a buggy app:


    Code:
    D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 92ms 
    D/dalvikvm( 2216): GC freed 6646 objects / 313032 bytes in 104ms 
    D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
    D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
    D/dalvikvm( 1253): GC freed 281 objects / 12688 bytes in 93ms 
    D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
    D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
    D/dalvikvm(   75): GC freed 41839 objects / 1963448 bytes in 88ms
    D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 94ms 
    D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
    D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8
    D/dalvikvm( 2216): GC freed 6657 objects / 314648 bytes in 35ms D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
    D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
    D/dalvikvm( 1253): GC freed 279 objects / 12640 bytes in 94ms 
    D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
    D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 
    D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 60ms 
    D/dalvikvm( 2216): GC freed 6661 objects / 314192 bytes in 104ms 
    D/NetworkLocationProvider(   75): onCellLocationChanged [***] 
    D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8
    As you can see the app (BeautifulWidgets) was constantly trying to remove the same updates and thus draining my battery for no reason. This was happening every 10seconds (!!).

    Uninstalling those crappy apps should help your battery life (and hope a future update of that app fixes it)

    The less you see in the logcat the better


    Starting with a fresh log

    If you want to clear the log and only see what's happening on your phone from now on, go to adb shell (step 4) and then type logcat -c. This clears the log and then type logcat.

    So all those of you having battery drains, please get a logcat to see whats eating your battery. Hope this helps

    Source-HOW TO: troubleshoot bad battery life with logcat - Android Forums

    EDIT-Leshak if you find this appropriate can we add it to wiki?
    Last edited by munchy_cool; 10-01-2010 at 05:30 PM.
    d0n't drink and driv3, y0u might hit a bump and dr0p y0ur b33r .. Ch33rs
    Samsung Spica (CM7) | Nexus One (CM7) | Galaxy Nexus (AOKP) | PS3 Slim (Rebug 3.55)

  2. [translate]    #2
    Moderator
    Join Date
    Jun 2010
    Location
    Iasi, Romania
    Posts
    697

    Default

    You must be s!%#@ me... is Beautiful Widgets the reason of my battery's extremely short life? I know I have Wi-Fi always turned on at home, but I'm going to see what happens without Beautiful Widgets. If it's because of it... I'm going to go berserk ) (as I had some biiig problems with the battery when I needed it). Thanks for the tip.
    No brain farts!

    Devices:
    Samsung Galaxy Lite Spica I5700 - CyanogenMod 9
    Samsung Wave S8500 - Android Ice Cream Sandwich 4.0.4 / Bada OS 2

  3. [translate]    #3
    Moderator
    Join Date
    May 2010
    Location
    h3LL
    Posts
    3,498

    Default

    Quote Originally Posted by bboylalu View Post
    You must be s!%#@ me... is Beautiful Widgets the reason of my battery's extremely short life? I know I have Wi-Fi always turned on at home, but I'm going to see what happens without Beautiful Widgets. If it's because of it... I'm going to go berserk ) (as I had some biiig problems with the battery when I needed it). Thanks for the tip.
    this was just an example man, am not pointing fingers at any app, maybe there was a bug in the version which may have been fixed...

    anyways you can go and check it out and give us the feedback.
    d0n't drink and driv3, y0u might hit a bump and dr0p y0ur b33r .. Ch33rs
    Samsung Spica (CM7) | Nexus One (CM7) | Galaxy Nexus (AOKP) | PS3 Slim (Rebug 3.55)

  4. [translate]    #4
    Moderator
    Join Date
    Jun 2010
    Location
    Iasi, Romania
    Posts
    697

    Default

    This is unbelievable man... It's been unplugged for 3 hours, wi-fi on, moderate usage and only 5% is gone :|. So Beautiful Widgets was the problem. I was really concerned about my battery's life, but it seems it's fine now. Thank you very much for the tip. I'll get back with more feedback after playing some games .

    Besides, the phone seems snapier all of a sudden :|.
    Last edited by bboylalu; 10-01-2010 at 08:52 PM.
    No brain farts!

    Devices:
    Samsung Galaxy Lite Spica I5700 - CyanogenMod 9
    Samsung Wave S8500 - Android Ice Cream Sandwich 4.0.4 / Bada OS 2

  5. [translate]    #5
    Moderator
    Join Date
    May 2010
    Location
    h3LL
    Posts
    3,498

    Default

    Quote Originally Posted by bboylalu View Post
    This is unbelievable man... It's been unplugged for 3 hours, wi-fi on, moderate usage and only 5% is gone :|. So Beautiful Widgets was the problem. I was really concerned about my battery's life, but it seems it's fine now. Thank you very much for the tip. I'll get back with more feedback after playing some games .

    Besides, the phone seems snapier all of a sudden :|.
    thanks man , glad to help you.
    d0n't drink and driv3, y0u might hit a bump and dr0p y0ur b33r .. Ch33rs
    Samsung Spica (CM7) | Nexus One (CM7) | Galaxy Nexus (AOKP) | PS3 Slim (Rebug 3.55)

  6. [translate]    #6
    Senior Member
    Join Date
    Apr 2010
    Location
    Austria
    Posts
    769

    Default

    nice explained munchy !

  7. [translate]    #7
    Moderator
    Join Date
    May 2010
    Location
    h3LL
    Posts
    3,498

    Default

    Quote Originally Posted by markus75 View Post
    nice explained munchy !
    dude, check the original link at the bottom.actually a lot of people complain about battery life on spica so i went about looking to find out whats eating ur battery and i found this out. hope we now have less people complaining about battery life.
    d0n't drink and driv3, y0u might hit a bump and dr0p y0ur b33r .. Ch33rs
    Samsung Spica (CM7) | Nexus One (CM7) | Galaxy Nexus (AOKP) | PS3 Slim (Rebug 3.55)

  8. [translate]    #8
    Senior Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    142

    Default

    or just use alogcat?

    im sorry, but i saw something dont understand in my logcat.


    Code:
    D:/dalvikvm(11061): GetFieldID: unable to find field L java/util/HashMap;/loadFactor :F

    occationally it keeps spamming my screen, but i am unable to trace back which app caused this, Im assuming this has something to do with antibyte's FE8b7?
    Last edited by kevinkoh; 10-02-2010 at 04:24 AM.

  9. [translate]    #9
    Moderator
    Join Date
    May 2010
    Location
    h3LL
    Posts
    3,498

    Default

    am still learning to comprehend logs.
    d0n't drink and driv3, y0u might hit a bump and dr0p y0ur b33r .. Ch33rs
    Samsung Spica (CM7) | Nexus One (CM7) | Galaxy Nexus (AOKP) | PS3 Slim (Rebug 3.55)

  10. [translate]    #10
    Member
    Join Date
    Sep 2010
    Location
    Bandung
    Posts
    36

    Default

    well thank you munchy_cool for bringing this thread up!
    battery life has been a big issue to me, and this thread comes at the right time!

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •