Bulk Emailing

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Sunday, 22 July 2012

Eclipse EGIT, Download Code, Attach Framework code & Debug

Posted on 12:17 by Unknown
This article explains procedure to download Android source (few important Apps and Framework base code) using Eclipse EGit plugin and then attach framework code to debug important framework classes (e.g. Activity etc.).
  1. Install EGit
  2. Download Source from GIT Repository
  3. Attach Framework code
  4. Debug
Download EGit Plug-in
EGit is a GIT plugin for Eclipse which helps to mange GIT clone, Check-ins, Sync etc. from your Eclipse workspace.
Eclipse (Version: 3.7.x) -> Help -> Install New Software -> "Add" - "http://download.eclipse.org/egit/updates".
Once the plug-in installation is successful, you'll find a new Eclipse View perspective- "Git Repository Exploring"

  
Download Android source
To download code from Android GIT repository, we need to create "local Git clone". Each local clone is associated with Remote Clone URL.  
https://android.googlesource.com/ lists Git Repository URLs for different sections of Android source code (platform, kernel etc.).
Kindly note:
The repository URL for Platform (https://android.googlesource.com/platform/manifest), doesn't recursively download complete platform code (e.g. /platform/frameworks/base, /platform/packages/app), rather it downloads default.xml which contains Git URL for individual platform components.
If you are using EGit, you need to separately download code for each components of platform (e.g. framework/base, packages/app/Contact etc.)

Following section describes procedure to download code for Calendar application and Framework (/framework/base)-
Git URL for Calendar- https://android.googlesource.com/platform/packages/apps/Calendar
Git URL for Framework- https://android.googlesource.com/platform/frameworks/base

Open the Git Repository Perspective-
  

There are 3 important buttons- "Add an Existing Repo", "Clone a Remote Repo" and "Create a New Repo".
Click on the Git Icon with blue arrow ("Clone a Remote Repo") to create a local clone of Android Jelly Bean source.
 

Press "Next". It will communicate with Google Server and download the list of available branches. You need to select relevant Android source branch, in this case "jb-release"-
 

Press "Next". In the successive screen, you need to Select the location where you want to create Local clone of this remote repository. Make sure you checked "Import all existing projects after clone finishes", this will instruct Egit to download the source code.
 

Click "Finish". If all above steps works fine, it will show progress bar and download source code-
 

Follow the same steps to clone Framework base repository. Framework code base will of around 1 GB and you need to increase Eclipse max Heap size to 1GB, otherwise Git Cloning process will fail.

Following screenshot shows both the clones-

Attach Framework base
"Import" the Calendar Application code as Android Project (ignore compilation errors).

To attach framework code, Right-click on "android.jar" and mention the framework source location (location of Framework code that we downloaded in the above step).
 
Once you mention the source location, Eclipse automatically does the indexing based on Package and Java file name. Now, if you click on "Activity.class", it will open the attached Jelly Bean Activity.java file-
 
We are going good. We have downloaded latest Android 4.1 Calendar application and Framework Base source code, we have attached the framework source with android.jar and Eclipse has done necessary indexing to find out respective Java file. So, all set to do the Framework Level Debugging.

Debugging
Lets set a break-point at the entry of Calendar application and then we'll debug files (both Calendar and Framework files).
For Calendar application, entry point or Main Launcher is com.android.calendar.AllInOneActivity. I'll set the break-point at the very beginning i.e. onCreate()-
Now, launch the Emulator, once Emulator is boot-up, you can find a list of already running processes and "Calendar" is one of them. To start the debugging, we need to attach Eclipse Remote debugger with Calendar process ID.
Select the Calendar process ID on DDMS and then click on Debug button (green color bug icon). It will attach Java remote debugger framework to Android Calendar process 8614.

We can also follow Debug Configuration option to attach Java Remote debugger with Android process-
  

As we have set the break-point at onCreate() method of Calendar application, if we launch Calendar from emulator, this break-point will hit and Eclipse will open "Debug Perspective". Press F5 to move into implementation of getSharedPreference() method.
     
I guess there is still one more question, how do I put break-point on Framework class e.g. Activity.java, I'll cover this topic in my next post.
Email ThisBlogThis!Share to XShare to Facebook
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Weekend at Yeouido (Han River Cruise)
    Yeouido is one of the Han River Cruise boarding points. It has a wonderful river side park (Yeouido P...
  • CityWeather
    Update: Release 1.1 has been uploaded. It will now provide weekly forecast of your selected cities. Download   CityWeather is an Android...
  • Few Multi-Threading Implementations
    Sequential Producer & Consumer In my first example, I will demonstrate an implementation to solve ...
  • Accessing Yahoo Finance API
    Since last few days I was wondering the right set of Web Service to read Country wise Stock Exchange index information . I found a bunch of ...
  • Regular Expression in JavaScript
    I was struggling to get familiar with JavaScript's Regular expression handling and thought my learning might help others. Here I'll...
  • Alphanumeric Random Number
    Sometime basic things becomes tricky :-) Was trying to find out ways to generate some alphanumeric random number whose size (i.e. number of ...
  • Binary Search Tree in Java
    This post is a part of my continuous effort to just implement few of the important data structures in ...
  • QuickSort in Java
    This post is a part of my continuous effort to just implement few of the important data structures in Java. Please find my previous post on ...
  • InDroid- Access to Android's Hidden API
    I have started one project " InDroid " to expose and share Hidden and Internal methods and variables of Android platform which are...
  • Image Geo Tagging for Android
    " onMap " is an Image Geo Tagging application, which can read EXIF header of images stored in your Android device and Map them ov...

Blog Archive

  • ►  2013 (6)
    • ►  September (2)
    • ►  May (1)
    • ►  April (1)
    • ►  February (1)
    • ►  January (1)
  • ▼  2012 (4)
    • ▼  July (2)
      • Eclipse EGIT, Download Code, Attach Framework code...
      • Bulk Email Sender
    • ►  March (1)
    • ►  January (1)
  • ►  2011 (11)
    • ►  November (1)
    • ►  October (2)
    • ►  August (1)
    • ►  June (1)
    • ►  April (2)
    • ►  March (3)
    • ►  January (1)
  • ►  2010 (27)
    • ►  December (2)
    • ►  November (3)
    • ►  September (2)
    • ►  August (4)
    • ►  July (4)
    • ►  June (7)
    • ►  May (5)
Powered by Blogger.

About Me

Unknown
View my complete profile