Author: Zambia chicks
Since its launch, Android has been favored and sought after by developers as an open source. Developers of most Android applications will refer to Dev guide. If you want to gain an in-depth understanding of Android, you must refer to the underlying source code to make it more straightforward.
The Android version control tool is git (distributed version control tool). Therefore, before preparing to download the source code, make necessary preparations, if you have never touched on some of the tools and commands mentioned below, it doesn't matter. I will provide some references after reading the tutorial, but now we need to complete our main task (to load the source code) first ).
Preparation tools:
1. msysgit (distributed version control system in Windows );
A ):Http://115.com/file/bhgp6gd1
2, libiconv-2.dell, libcurl-4.dll;
A ):Http://115.com/file/e6tq3pgr
A) install msysgit
Run msysgit-fullinstall-1.7.7.1-preview20111027.exe and select the installation directory (my installation path is c: \ msysgit \). It is very easy to run the following steps:
After the installation is complete, you need to append the $ home \ bin \ variable to the environment variable path. Take my example (C: \ msysgit \ bin ).
In addition, msysgit will call the libiconv-2.dll, libcurl-4.dll and other class libraries at work, so you need to add additional class library, unzip the DLL file we just downloaded, copy and paste it to the $ home \ bin directory (here I am c: \ msysgit \ bin ).
B) after completing the preceding steps, msysgit is basically configured. msysgit is a distributed version management tool (DVCs ), unlike traditional integrated version management tools (CVCs) such as SVN and CVS, CVCs may face the risk of data loss in all projects after the server goes down, although the client may retain copies of the server, you cannot guarantee the integrity of project data. DVCs does not record the differences between versions. Each version is saved as a snapshot in the file system. Each time you checkout, the client will clone all the data and images of the server, in this way, when the server goes down, you can use the client's image file to completely restore server data. More will be introduced later. Next we will clone the GIT source code of Android.
Since February Http://android.git.kernel.org/ The website has been attacked by hackers. Recently, the website is preparing to migrate data, but it seems that it has not been completed yet. So I have no better way to browse the project tree under the entire framework, here I will download the android base. git example ( Http://android.googlesource.com/platform/frameworks/base.git ). We have retained the download website. Thank you.
Create a working directory. Here I am using C: \ msysgit \ Android framework SRC to save the android source code, open cmd, switch to the directory, and enter git clone.
Http://android.googlesource.com/platform/frameworks/base.git Press enter to start the download. Then we can have a cup of coffee and wait. After the download is complete, there will be a progress indicator.
100%.
The last download time is over two hours (# ‵ ').
B) Link Android source code in Eclipse:
After that, Open c: \ msysgit \ Android framework SRC \ base \, Which is the source code file we just downloaded.
Generally, we press Ctrl + the left mouse button under eclipse to click a class name and switch to the source code file of the class, which is convenient and quick. So how to associate the android source code with eclipse?
1) Open eclipse and create the android project "srcattach". android2.2 is used here. Expand the project directory, right-click Android. jar-> properties-> JAVA source attachment, and find the following sentence: Android library 'which does not allow user modifications to source attachments on its entries.
Very depressing. The ADT plug-in does not allow source code Association. I have found a lot of information and I will not elaborate on the specific solution. I will provide reference materials for the solution later.
2) The solution is to open the android SDK Installation Directory D: \ Program Files \ Android-SDK-Windows \ platforms \ Android-8, and create a folder sources; copy the downloaded file c: \ msysgit \ Android framework SRC \ base \ core \ Java \ Android and COM to the sources directory and restart eclipse, the ADT automatically associates with the source code in sources.
This time we try to see if the solution works. We have created activity01.java,Code:
package com.jason;
import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.TextView;
public class ActivityStyle extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_01);
}
}
Press ctrl and click the activity class name. This is switched to the activity source code file:
Okay, it seems that all our work is basically done here. When we download the source code of other projects under the android framework, copy it together and put it under sources.
I will provide you with online references later. If you have time, you may wish to take a look at them. If there are errors or details in this article, I hope you can criticize and correct them. I will improve them in time.
Appendix:
A) usage of the GIT tool:Http://blog.csdn.net/andy_android/article/details/7001557
B) git open source Tutorial:Http://opengit.org/open? F = progit_01-introduction
C) eclipse-related Android source code solution:Http://stuffthathappens.com/blog/2008/11/01/browsing-android-source-in-eclipse/