Android移动操作系统源代码

 

Get Android Source Code

This document describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine.

Related reading:

 

What's in the source?

To see snapshots and histories of the files available in the public Android repositories, visit the GitWeb  web interface.

The source is approximately 2.6GB in size. You will need 6GB free to complete the build.

Setting up your machine

To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported.

Linux

The Android build is routinely tested in house on recent versions of Ubuntu (10.04 and later), but most distributions should have the required build tools available. Reports of successes or failures on other distributions are welcome.

In general you will need:

  • Python 2.4, which you can download from python.org .
  • JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download either from java.sun.com .
  • Git 1.5.4 or newer. You can find it at http://git.or.cz/ .

 

Ubuntu Linux (64-bit)

The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.

Java 6: for Gingerbread and newer

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk
sudo update-java-alternatives -s java-6-sun

 

Java 5: for Froyo and older

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse"
sudo apt-get update
sudo apt-get install sun-java5-jdk
sudo update-java-alternatives -s java-1.5.0-sun

 

 

To set up your development environment, install the following required packages:

$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

 

You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.

Running Linux in a virtual machine
If you are running Linux in a virtual machine, you will need at least 1.5GB of RAM and 10GB or more of disk space in order to build the Android tree.

Mac OS X

To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.4 (Tiger), 10.5 (Leopard), or 10.6 (Snow Leopard). The Android build system and tools do not support the obsolete PowerPC architecture.

Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.

Creating a case sensitive disk image

If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. To create the image, launch Disk Utility and select "New Image". A size of 8 GB is sufficient, or more if you prefer. Be sure to select "case sensitive, journaled" as the volume format.

This will create a .dmg file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your ~/.bash_profile  to mount the image when you execute "mountAndroid":

# mount the android file image
function mountAndroid{ hdiutil attach ~/android.dmg-mountpoint /Volumes/android; }
Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.

 

To set up your Mac OS development environment, follow these steps:

  1. Install XCode from http://developer.apple.com . We recommend version 3.0 or newer. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.
  2. Install MacPorts from http://www.macports.org/ .
  3. Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add
    export PATH=/opt/local/bin:$PATH
    to your ~/.bash_profile .
  4. Get make, git, and GPG packages from port:
    $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
    If using Mac OS 10.4, also install bison:
    $ POSIXLY_CORRECT=1 sudo port install bison
  5. Temporary step: There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:

    Edit /opt/local/etc/macports/sources.conf  and a line that says

    file:///Users/Shared/dports
    above the rsync line. Then create this directory:
    $ mkdir /Users/Shared/dports
    In the new dports  directory, run
    $ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
    Create a port index for your new local repository:
    $ portindex /Users/Shared/dports
    Finally, install the old version of gmake with
    $ sudo port install gmake @3.81

     

  6. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your ~/.bash_profile :
    # set the number of open files to be 1024
    ulimit -S -n 1024

 

Installing Repo

Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Using Repo and Git .

To install, initialize, and configure Repo, follow these steps:

  1. Make sure you have a bin/ directory in your home directory, and that it is included in your path:
    $ mkdir ~/bin
    $ PATH=~/bin:$PATH
  2. Download the Repo script and ensure it is executable:
    $ curl http://android.git.kernel.org/repo > ~/bin/repo
    $ chmod a+x ~/bin/repo

Initializing a Repo client

After installing Repo, set up your client to access the android source repository:

  1. Create an empty directory to hold your working files:
    $ mkdir  directory
    $ cd  directory
  2. Run repo init  to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
    $ repo init -u git://android.git.kernel.org/platform/manifest.git
    To check out a branch other than "master", specify it with -b:
    $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
  3. When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with aregistered Google account . Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.
A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a  .repo  directory where files such as the manifest will be kept.

 

Getting the files

To pull down files to your working directory from the repositories as specified in the default manifest, run

$ repo sync
For more about  repo sync  and other Repo commands, see  Using Repo and Git .

The Android source files will be located in your working directory under their project names.

Verifying Git Tags

Load the following public key into your GnuPG key database. The key is used to sign annotated tags that represent releases.

$ gpg --import
Copy and paste the key(s) below, then enter EOF (Ctrl-D) to end the input and process the keys.
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV 
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgk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M5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb 
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA 
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo 
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ 
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l 
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D 
-----END PGP PUBLIC KEY BLOCK-----
After importing the keys, you can verify any tag with
$ git tag -v  tagname

 

Building the code

To build the files, run envsetup, lunch, and make from within your working directory:

$ cd ~/ directory
$ source build/envsetup.sh
$ lunch
$ make
If your build fails because of a missing  run-java-tool , try setting the  ANDROID_JAVA_HOME  environment variable before making.
$ export ANDROID_JAVA_HOME=$JAVA_HOME

 

What's next?

See Using Eclipse  for instructions on how to use an IDE for Android platform development. To learn about reporting an issue and searching previously reported issues, see Report bugs . For information about editing the files and uploading changes to the code-review server, see Contribute .

 

http://source.android.com/source/download.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一个简单的程序,4个人20天的心血.package zhuyemian; import java.awt.BorderLayout; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JToolBar; import javax.swing.UIManager; import javax.swing.border.EtchedBorder; //import com.qhit.LandAppend; //import com.qhit.PasswordAmend; import Kehuxinxi.Kehumain; import Shouhoumain.Main; import Xiaoshouxinxi.Xiaoshoumain; import Chanpinxinxi.Chanpinmain; public class Zhuyemian extends JFrame implements Runnable{ MyPanel panel = new MyPanel(); JLabel label; public Zhuyemian() { super(); this.setIconImage(new ImageIcon("shoujitubiao.jpg").getImage());//在标题上的图片 this.setTitle("手机销售信息管理");//标题 this.setResizable(false);//大小可否改变 setSize(1024, 768); getContentPane().setLayout(null); getContentPane().add(panel); panel.setBounds(142, 37, 900, 738); panel.setLayout(null); final JMenuBar menuBar = new JMenuBar(); menuBar.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 setJMenuBar(menuBar); final JMenu menujibencaozuo = new JMenu(); menujibencaozuo.setText("基本操作"); menuBar.add(menujibencaozuo); final JMenuItem newItemMenuItem_1 = new JMenuItem(); newItemMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { new Kehumain(); } }); newItemMenuItem_1.setText("客户信息"); menujibencaozuo.add(newItemMenuItem_1); final JMenuItem newItemMenuItem = new JMenuItem(); newItemMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { new Chanpinmain(); } }); newItemMenuItem.setText("产品信息"); menujibencaozuo.add(newItemMenuItem); final JMenuItem newItemMenuItemxiaoshouxinxi = new JMenuItem(); newItemMenuItemxiaoshouxinxi.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { new Xiaoshoumain(); } }); newItemMenuItemxiaoshouxinxi.setText("销售信息"); menujibencaozuo.add(newItemMenuItemxiaoshouxinxi); final JMenuItem newItemMenuItemshouhouxinxi = new JMenuItem(); newItemMenuItemshouhouxinxi.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { new Main(); } }); newItemMenuItemshouhouxinxi.setText("售后信息"); menujibencaozuo.add(newItemMenuItemshouhouxinxi); final JMenu menugongju = new JMenu(); menugongju.setText("工具"); menuBar.add(menugongju); final JMenuItem newItemMenuItemjisuanqi = new JMenuItem(); newItemMenuItemjisuanqi.setText("计算器"); newItemMenuItemjisuanqi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { Runtime.getRuntime().exec("calc.exe"); //设置运行任何系统可执行的程序----计算器 } catch (IOException e) { e.printStackTrace(); } } }); menugongju.add(newItemMenuItemjisuanqi); final JMenuItem newItemMenuItemjishiben = new JMenuItem(); newItemMenuItemjishiben.setText("记事本"); newItemMenuItemjishiben.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { Runtime.getRuntime().exec("notepad.exe"); //设置运行任何系统可执行的程序----记事本 } catch (IOException e) { e.printStackTrace(); } } }); menugongju.add(newItemMenuItemjishiben); final JMenu menu = new JMenu(); menu.setText("密码设置"); menuBar.add(menu); final JMenuItem newItemMenuItem_2 = new JMenuItem(); newItemMenuItem_2.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { // LandAppend ls = new LandAppend(); } }); newItemMenuItem_2.setText("注册管理员"); menu.add(newItemMenuItem_2); final JMenuItem newItemMenuItem_3 = new JMenuItem(); newItemMenuItem_3.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { // PasswordAmend frame = new PasswordAmend(null); } }); newItemMenuItem_3.setText("修改密码"); menu.add(newItemMenuItem_3); final JButton xiaishouxinxi = new JButton(); xiaishouxinxi.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { Xiaoshoumain xsm =new Xiaoshoumain(); } }); xiaishouxinxi.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/xiaoshouxinxi.jpg")); xiaishouxinxi.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 xiaishouxinxi.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); xiaishouxinxi.setText(""); xiaishouxinxi.setBounds(0, 369, 136, 139); getContentPane().add(xiaishouxinxi); final JButton shouhouxinxi = new JButton(); shouhouxinxi.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { Main mm=new Main(); } }); shouhouxinxi.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/shouhouxinxi.jpg")); shouhouxinxi.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 shouhouxinxi.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); shouhouxinxi.setText(""); shouhouxinxi.setBounds(0, 537, 136, 139); getContentPane().add(shouhouxinxi); final JButton chanpinxinxi = new JButton(); chanpinxinxi.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { Chanpinmain cpm=new Chanpinmain(); } }); chanpinxinxi.setBounds(0, 202, 136, 134); getContentPane().add(chanpinxinxi); chanpinxinxi.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); chanpinxinxi.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/chanpinxinxi.jpg")); chanpinxinxi.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 chanpinxinxi.setText(""); final JButton kehuxinxi = new JButton(); kehuxinxi.setBounds(0, 37, 136, 134); getContentPane().add(kehuxinxi); kehuxinxi.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { new Kehumain(); } }); kehuxinxi.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/kehuxinxi.jpg")); kehuxinxi.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 kehuxinxi.setText(""); this.setCursor(new Cursor(Cursor.HAND_CURSOR));//设置鼠标形状为手型 label = new JLabel(); label.setText(""); label.setBounds(805, 0, 213, 36); getContentPane().add(label); final JToolBar toolBar = new JToolBar(); toolBar.setBounds(2, 1, 1016, 34); getContentPane().add(toolBar); final JButton Bangzhu= new JButton(); toolBar.add(Bangzhu); Bangzhu.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/帮助.png")); Bangzhu.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 Bangzhu.setText("帮助"); final JButton dayin = new JButton(); toolBar.add(dayin); dayin.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/print.png")); dayin.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 dayin.setText("打印"); final JButton tuichu = new JButton(); toolBar.add(tuichu); tuichu.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { int aa=JOptionPane.showConfirmDialog(null, "你确认要退出吗?","确定",2); if(aa==JOptionPane.YES_OPTION){ dispose(); } } }); tuichu.setIcon(SwingResourceManager.getIcon(Zhuyemian.class, "/退出.png")); tuichu.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));//设置鼠标形状为默认的箭头 tuichu.setText("退出"); /*******************************************设定窗体的位置(居中)*******************************************/ Toolkit kit=Toolkit.getDefaultToolkit(); Dimension screen=kit.getScreenSize(); int height=screen.height;//当前屏幕高度 int width=screen.width;//当前屏幕宽度 this.setLocation((width-this.getWidth())/2,(height-this.getHeight())/3); this.setVisible(true); //启动多线程 Thread th =new Thread(this); th.start(); } /*******************************************时钟run方法*******************************************/ public void run() { while(true){ Date d =new Date(); SimpleDateFormat sdf =new SimpleDateFormat("yyyy-M-dd hh:mm:ss"); String str =sdf.format(d); label.setText(str); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public static void main(String[] args) { //改变观感 //org.jvnet.substance.SubstanceLookAndFeel try { UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } new Zhuyemian(); } } /******************************************添加背景图片*******************************************/ class MyPanel extends JPanel{ //1.从写这个方法 public void paintComponent(Graphics g) { ImageIcon icon = new ImageIcon("zhujiemian.jpg"); g.drawImage(icon.getImage(), 0, 0, this.getWidth(), this.getHeight(), this); } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值