Android SDK Fine Print and Debugging

Posted: September 25, 2009 in Android, Java, Mobile
Tags: ,

Sometimes it helps to read the fine print for example, adb:

You can use the adb commands pull and push to copy files to and from an emulator/device instance’s data file. Unlike the install command, which only copies an .apk file to a specific location, the pull and push commands let you copy arbitrary directories and files to any location in an emulator/device instance.

combined with startMethodTracing(‘tracefileName’)  and  stopMethodTracing() and dumpHprofData(‘filename’) can make debugging using an ANT build script a whole lot easier and more fun. And there is some more interesting stuff in the android.os.debug class. For example buffer size of *.trace files defautls to 8 megs so one could supply a higher buffer size amount for the startMethodTracing() calls. Basically, what yu can o dis have the *trace fiel created with startMethodTracing() and the  *hprof file created with dumpHprofData() named by by the moethod as you are calling those debug statements within your method. You woudl set it up so that you have a new dirsuch as:

startMethodtracing(‘/sdcard/trace/methodName.trace’);

dumpHprofData(‘/scard/hprof/methodName.hprof’);

Then its simple manner to do an:

adb pull /sdcard/trace /userhome/project/trace

adb pull /sdcard/hprof /userhome/project/hprof

..which of course makes it a lot easier. And since android.os.Debug is a wrapper on VMDebug lets check that class for juts a second and see what other goodies we can find.  Ah aha!

startInstructionCounting(), stopInstructionCounting(), and getInstructionCounts() leap to focus. Why? If you have constructed any thing involving memory or process time such as mathematics library, a graphics library, or a game engine you are in the mobile space attempting to optimize of the last amount of executed instructions. Having ways to log the amount of instructions a method might use to the log file becomes somewhat important. In this case to get access to call you need to use dalvik.system.VMDebug as its public.

Reblog this post [with Zemanta]
Advertisements
Comments
  1. jetti says:

    I want to print pages from Android Emulator but am unable
    to print the pages on the emulator,it seems like it is not connected.
    Is this possible with the emulator?

    Or what am i doing wrong?

    Am using Android SDK 1.6

  2. midoub says:

    hi,
    do know, how I can change logfiles location, I mean, I want save logfiles in Sdcard on live.
    thank you for your help.
    Best regards.

  3. jetti says:

    Hi, midoub
    You said that,save logfiles in sdcard but i want to print the pages from not only sdcard butalso running application on emulator.
    If we save log files in sdcard also i unable to print the pages.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s