zoukankan      html  css  js  c++  java
  • ubuntu下编译android源代码

    1. 安装ubuntu,我安装的是ubuntu9.10

    2.    安装JDK 5.0

    1:根据官方文档里所说,源代码的编译必须使用JDK5才能编译的了,所以这里我们使用jdk5

    2:   需要先更新源,在终端里执行 sudo gedit /etc/apt/sources.list

    3: 在弹出的文档里最后加入如下指令:

           把以下2行拷贝到文档最后面:

                deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse

                deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

           保存退出。

    4:   执行 sudo apt-get update 更新源.

    5:   配置编译环境并下载JDK5

           在终端中执行

           sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

       碰到确认的按Y后按下回车继续

    6: 等待安装完毕

    3. 下载anroid源代码后,并解压(下载源代码的方法有很多,这里就不多说了.)

    4. 编译源代码

        从终端进入解压好的源代码目录下

      编译前需要修改源代码中的一些代码,不然会编译不过去

      改文件
      development/emulator/qtools/trace_reader.cpp
      1012
      const char *end = rindex(mmap_path, '@');
      1015
      const char *start = rindex(mmap_path, '/');

      development/emulator/qtools/dmtrace.cpp
      166
      char *paren =(char *) strchr(name, '(');
      183
      char *dot =(char *) strrchr(name, '.');

        输入make -j 8 编译源代码.需要等很长很长时间(-j 8表示用8CPU来编译,前提你是8CPU)

    5. 配置环境:gedit .bashrc

       将一下2行添加到文件末尾:

           export PATH=$PATH:/home/xxx/android/out/host/linux-x86/bin

             export ANDROID_PRODUCT_OUT=/home/xxx/android/out/target/product/generic

    6. 编译模块:

     修改了android的相关源代码后,在源代码的目录下,执行: . build/envsetup.sh

         然后,进入到修改的源代码所属包的目录下,执行:mm

         在源代码的目录下,执行: make snod

               最后,在系统目录下,执行:emulator   ,就可以在模拟器上看到修改后的结果。

     

       android中的一个应用程序可以单独编译,编译后要重新生成system.img
    在源码目录下执行
    $ . build/envsetup.sh .后面有空格)
    就多出一些命令:
    - croot:   Changes directory to the top of the tree.
    - m:       Makes from the top of the tree.
    - mm:      Builds all of the modules in the current directory.
    - mmm:     Builds all of the modules in the supplied directories.
    - cgrep:   Greps on all local C/C++ files.
    - jgrep:   Greps on all local Java files.
    - resgrep: Greps on all local res/*.xml files.
    - godir:   Go to the directory containing a file.
    可以加—help查看用法
    我们可以使用mmm来编译指定目录的模块,如编译联系人:
    $ mmm packages/apps/Contacts/
    编完之后生成两个文件:
    out/target/product/generic/data/app/ContactsTests.apk
    out/target/product/generic/system/app/Contacts.apk
    可以使用
    $ make snod
    重新生成system.img,再运行模拟器

     

             最后,在系统目录下,执行:emulator   ,就可以在模拟器上看到修改后的结果。

  • 相关阅读:
    window对象的方法
    JS注册事件
    JS总结
    JS 扩展方法prototype
    Codeforces 460D Little Victor and Set(看题解)
    Codeforces 891C Envy
    Codeforces 251C Number Transformation
    Codeforces 490F Treeland Tour 树形dp
    Codeforces 605C Freelancer's Dreams 凸包 (看题解)
    几何模板
  • 原文地址:https://www.cnblogs.com/qwhg/p/1624835.html
Copyright © 2011-2022 走看看