Android 编译源码相关

一. 首先在Android源代码目录下的build目录下,有个脚本文件envsetup.sh,执行这个脚本文件后,就可以获得一些有用的工具:

USER-NAME@MACHINE-NAME:~/Android$ .  ./build/envsetup.sh

      注意,这是一个source命令,执行之后,就会有一些额外的命令可以使用:

      - 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命令来编译指定的模块,例如Email应用程序:

USER-NAME@MACHINE-NAME:~/Android$ mmm packages/apps/Email/

      编译完成之后,就可以在out/target/product/generic/system/app目录下看到Email.apk文件了。Android系统自带的App都放在这具目录下。另外,Android系统的一些可执行文件,例如C编译的可执行文件,放在out/target/product/generic/system/bin目录下,动态链接库文件放在out/target/product/generic/system/lib目录下,out/target/product/generic/system/lib/hw目录存放的是硬件抽象层(HAL)接口文件,后面的文章里面,我们会陆续提及到,敬请关注。



出现

frameworks/av/camera/cameraserver/Android.mk:18: Target has integrated cameraserver into mediaserver. This is weakening security measures introduced in 7.0

find: ‘/home/xuanan/android/lineage/out/target/common/obj/SHARED_LIBRARIES/libwifi-hal-mock_intermediates’: No such file or directory

Starting build with ninja

ninja: Entering directory `.'

[  0% 14/48263] Lex: aidl <= system/tools/aidl/aidl_language_l.ll

FAILED: /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -o/home/xuanan/android/lineage/out/host/linux-x86/obj/STATIC_LIBRARIES/libaidl-common_intermediates/aidl_language_l.cpp system/tools/aidl/aidl_language_l.ll"

flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.

Aborted (core dumped)

[  0% 14/48263] target Java: libprotob...tobuf-java-nano_intermediates/classes)

Note: Some input files use unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

[  0% 14/48263] target Java: libphonen...number-platform_intermediates/classes)

ninja: build stopped: subcommand failed.

build/core/ninja.mk:151: recipe for target 'ninja_wrapper' failed

make: *** [ninja_wrapper] Error 1

make: Leaving directory '/home/xuanan/android/lineage'

解决方案:

This will do the trick:

export LC_ALL=C

Add it to yourbashrcfile or equivalent.

你可能感兴趣的:(Android 编译源码相关)