kk Blog —— 通用基础

date [-d @int|str] [+%s|"+%F %T"]

编译android4.4.2源码

android4.4.2和jdk下载 http://pan.baidu.com/share/home?uk=3691037096&view=share#category/type=0

http://www.cnblogs.com/zhx831/p/3550688.html

这篇文章主要记录了我是如何搭建Android编译环境,以及搭建当中遇到的问题以及解决方法。搭建环境依照官网进行,整个搭建环境分为两步:
1. 安装JDK
2. 安装相对应的库以及软件

1、安装JDK

官网上给出的办法是使用apt进行jdk的安装

1
2
3
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

但是我在按照这个方法进行安装是apt提示无法找到jdk安装包。 在更换了好几个source后都无法下载jdk。因此只能考虑手动安装。

1. 首先在Orecal官网下载JDK:

http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

需要注意的是,现在官方网站上最新的版本的JDK7, 但是这个这个版本是不能用于Android的编译的,一定要去下载JDK6. 希望看到的朋友不要在走我的弯路。

2. 创建jvm文件夹
1
sudo mkdir /usr/lib/jvm
3. 安装JDK6
1
2
3
sudo cp jdk-6u45-linux-x64.bin /usr/lib/jvm/
sudo chmod +x jdk-6u45-linux-x64.bin
sudo ./jdk-6u45-linux-x64.bin
4. 设置环境变量
1
2
3
4
5
sudo mv jdk1.6.0_45/ jdk6
export JAVA_HOME=/usr/lib/jvm/jdk6
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5. 使能环境变量
1
source ~/.bashrc
6. 设置JDK6为系统默认JDK

因为在ubuntu中默认JDK可能是OpenJDK,这里我们设置JDK6为我们默认的JDK

1
2
3
4
5
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk6/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk6/bin/javac 300
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk6/bin/javaws 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk6/bin/jar 300
sudo update-alternatives --config java
7. 至此JDK就安装好了,现在就可以在shell中查看Java版本
1
java -version

如果编译还提示java错误,就把java路径加到PATH中

1
PATH=$PATH:/usr/lib/jvm/jdk6/bin

2、安装相对应的库以及软件

根据官网上的指示我们需要安装如下软件包和lib

1
2
3
4
5
6
$ sudo apt-get install git gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
  • 我安装libgl1-mesa-glx:i386的时候提示要卸掉很多软件,就没装这个,也是能正常编译。

但是在安装过程中遇到了如下错误:

1
2
3
4
Errors were encountered while processing:
libc6-dev:i386
 
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决方法如下:

1
2
$ sudo apt-get install linux-libc-dev:i386
$ sudo apt-get install libc6-dev:i386

http://blog.csdn.net/yf210yf/article/details/9206269

http://www.cnblogs.com/qianxudetianxia/p/3681890.html

编译代码

进入源码根目录,编译初始化,在终端中执行:

1
source build/envsetup.sh

选择编译目标:

1
lunch 

选择第一个吧,或者直接

1
lunch aosp_arm-eng

开始编译

1
make -j4

3、5个小时左右吧

Android 完成编译的时候先执行 source build/envsetup.sh。 在这个shell 脚本中定义了 help, croot, m, mm, mmm 等 function

运行模拟器

在终端中执行:emulator

修改和编译系统应用代码

我们修改一下系统应用Mms的标题:

使用mm命令编译:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
xxx@ubuntu:~/Data/android/packages/apps/Mms$ mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.3.2.1.000.000
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_2ND_ARCH=
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
OUT_DIR=out
============================================
make:进入目录'/home/xxx/Data/android'
target R.java/Manifest.java: Mms (out/target/common/obj/APPS/Mms_intermediates/src/R.stamp)
warning: string 'menu_insert_smiley' has no default translation.
target Java: Mms (out/target/common/obj/APPS/Mms_intermediates/classes)
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
Copying: out/target/common/obj/APPS/Mms_intermediates/classes-jarjar.jar
Copying: out/target/common/obj/APPS/Mms_intermediates/emma_out/lib/classes-jarjar.jar
Copying: out/target/common/obj/APPS/Mms_intermediates/classes.jar
Proguard: out/target/common/obj/APPS/Mms_intermediates/proguard.classes.jar
ProGuard, version 4.10
Reading program jar [/home/xxx/Data/android/out/target/common/obj/APPS/Mms_intermediates/classes.jar]
// ... ...
target Dex: Mms
Copying: out/target/common/obj/APPS/Mms_intermediates/classes.dex
target Package: Mms (out/target/product/generic/obj/APPS/Mms_intermediates/package.apk)
nothing matches overlay file ic_contact_picture.png, for flavor ,,,,,,,,,,,,mdpi,,,,,,,
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
warning: string 'menu_insert_smiley' has no default translation.
warning: string 'menu_insert_smiley' is missing 19 required localizations: az_AZ en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU hy_AM ka_GE km_KH lo_LA mn_MN ne_NP si_LK zh_CN zh_HK zh_TW
dex2oatd I 21424 21424 art/dex2oat/dex2oat.cc:1082] dex2oat: out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=out/target/product/generic/dex_bootjars/system/framework/boot.art --dex-file=out/target/product/generic/obj/APPS/Mms_intermediates/package.apk --dex-location=/system/priv-app/Mms.apk --oat-file=out/target/product/generic/obj/APPS/Mms_intermediates/package.odex --android-root=out/target/product/generic/system --instruction-set=arm --instruction-set-features=default
dex2oatd I 21424 21424 art/dex2oat/dex2oat.cc:252] dex2oat took 1.189425041s (threads: 8)
Notice file: packages/apps/Mms/NOTICE -- out/target/product/generic/obj/NOTICE_FILES/src//system/priv-app/Mms.apk.txt
Install: out/target/product/generic/system/priv-app/Mms.apk
Install: out/target/product/generic/system/priv-app/Mms.odex
// ... ...
Install: out/target/product/generic/data/app/MmsTests.apk
Install: out/target/product/generic/data/app/MmsTests.odex
make:离开目录“/home/xxx/Data/android”

主要是生成了两个文件:
out/target/product/generic/system/priv-app/Mms.apk
out/target/product/generic/system/priv-app/Mms.odex

安装到手机

因为是系统应用,为了重启有效,使用push命令把两个文件push到模拟器中对应的位置:

1
2
3
4
5
6
// 注意现在一些核心的应用的位置由以前的system/app调整为了system/priv-app,不要push错了
/*
xxx@ubuntu:~/Data/android$ adb push out/target/product/generic/system/priv-app/Mms.odex /system/priv-app
2893 KB/s (2085348 bytes in 0.703s)
xxx@ubuntu:~/Data/android$ adb push out/target/product/generic/system/priv-app/Mms.apk /system/priv-app
3315 KB/s (1785258 bytes in 0.525s)

看模拟器的标题被替换了。类似了,你可以修改framework,替换内核

在 ~/.bashrc

添加环境变量:

1
2
export ANDROID_PRODUCT_OUT=~/code/android-4.2/out/target/product/generic
export ANDROID_SWT=~/code/android-4.2/out/host/linux-x86/framework/

备注:

执行emulator,出现如下错误:

1
2
3
4
5
6
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.

If you are an Android SDK user, please use '@<name>' or '-avd <name>'
to start a given virtual device (see -help-avd for details).
Otherwise, follow the instructions in -help-disk-images to start the emulator

解决:

1
2
source build/envsetup.sh 
lunch sdk-eng

然后再执行

1
emulator

可以启动模拟器


http://senrsl.blogspot.com/2015/03/s4shv-e300lkernelrom.html

三星S4韩版SHV-E300L源码编译(内核Kernel+ROM)

编译ROM

①准备工作

先看说明README_Platform.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    How to build Module for Platform
    - It is only for modules are needed to using Android build system.
    - Please check its own install information under its folder for other module.
    [Step to build]
    1. Get android open source.
        : version info - Android 4.4
        ( Download site : http://source.android.com )
    2. Copy module that you want to build - to original android open source
       If same module exist in android open source, you should replace it. (no overwrite)
        # It is possible to build all modules at once.
    3. You should add module name to 'PRODUCT_PACKAGES' in 'build\target\product\core.mk' as following case.
        case 1) e2fsprog : should add 'e2fsck' to PRODUCT_PACKAGES
        case 2) blkid : should add 'libkeyutils' to PRODUCT_PACKAGES
        case 3) libhyphenation : should add 'libkeyutils' to PRODUCT_PACKAGES
        case 4) KeyUtils : should add 'libkeyutils' to PRODUCT_PACKAGES
        case 5) libexifa : should add 'libexifa' to PRODUCT_PACKAGES
        case 6) libjpega : should add 'libjpega' to PRODUCT_PACKAGES
        ex.) [build\target\product\core.mk] - add all module name for case 1 ~ 5 at once
            PRODUCT_PACKAGES += \
                e2fsck \
                blkid \
                libhyphenation \
                libkeyutils \
                libexifa \
                libjpega \
                ebtables
    4. excute build command
        ./build_platform.sh
    Note :
    to build SBrowser (vendor/samsung/packages/apps/SBrowser),
    please refer to Buildme.txt at the folder mentioned above.

意思就是说分4部走,后面加了个注释。

分别是下载4.4的源码,把包里的要编译的模块拷进去(替换,非覆盖),增加要编译的模块到core.mk进行注册,执行编译脚本。

查看当前源码版本

1
2
3
4
5
6
senrsl@senrsl-ubuntu:~$ cd android/source/WORKING_DIRECTORY/
senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$ repo branches
*  android-4.4.2_r2          | in all projects
    master                    | in:
                                      abi/cpp
                                      ....

所有的版本号里没有叫4.4的,只有4.4.*的。。。。

好吧,就用这个。

②替换模块

1)external目录,把这些目录剪出来

1
2
3
4
5
6
7
8
9
10
11
12
    senrsl@senrsl-ubuntu:~/android/source/test/三星替换 /external$ ll
    总用量 40
    drwxrwxr-x 10 senrsl senrsl 4096  3月 30 14:53 ./
    drwxrwxr-x  4 senrsl senrsl 4096  3月 30 15:02 ../
    drwxrwxr-x 17 senrsl senrsl 4096  3月 20 13:35 chromium/
    drwxrwxr-x  9 senrsl senrsl 4096  3月 20 13:36 dnsmasq/
    drwxrwxr-x 19 senrsl senrsl 4096  3月 20 13:36 e2fsprogs/
    drwxrwxr-x  3 senrsl senrsl 4096  3月 20 13:36 gcc-demangle/
    drwxrwxr-x  4 senrsl senrsl 4096  3月 20 13:36 hyphenation/
    drwxrwxr-x 15 senrsl senrsl 4096  3月 20 13:36 iproute2/
    drwxrwxr-x 11 senrsl senrsl 4096  3月 20 13:36 iptables/
    drwxrwxr-x  4 senrsl senrsl 4096  3月 20 13:36 junit/

把这些目录放进去

1
2
3
4
5
6
7
8
9
10
11
12
13
14
    senrsl@senrsl-ubuntu:~$ cd android/source/SHV-E300L_KK_Opensource/Platform/external/
    senrsl@senrsl-ubuntu:~/android/source/SHV-E300L_KK_Opensource/Platform/external$ ll
    总用量 44
    drwxrwxr-x 11 senrsl senrsl 4096 10月 14 09:23 ./
    drwxrwxr-x  5 senrsl senrsl 4096  3月 30 13:10 ../
    drwxrwxr-x 17 senrsl senrsl 4096 10月  8 12:16 chromium/
    drwxrwxr-x  9 senrsl senrsl 4096 10月  8 09:07 dnsmasq/
    drwxrwxr-x 18 senrsl senrsl 4096 10月  8 09:07 e2fsprogs/
    drwxrwxr-x  2 senrsl senrsl 4096 10月  8 09:07 gcc-demangle/
    drwxrwxr-x  3 senrsl senrsl 4096 10月  8 09:07 hyphenation/
    drwxrwxr-x 14 senrsl senrsl 4096 10月  8 09:07 iproute2/
    drwxrwxr-x 10 senrsl senrsl 4096 10月  8 09:07 iptables/
    drwxrwxr-x  3 senrsl senrsl 4096 10月  8 09:07 junit/
    drwxrwxr-x 10 senrsl senrsl 4096 10月  8 12:23 webkit/

2)vendor目录,把vendor/samsung放进去

3)build目录,把这俩文件剪出来,把Platform里的放进去

1
2
3
4
5
6
7
8
9
    senrsl@senrsl-ubuntu:~/android/source/SHV-E300L_KK_Opensource/Platform/build$ tree
    .
    └── target
        ├── board
        │   └── generic
        │       └── BoardConfig.mk
        └── product
            └── core.mk
    4 directories, 2 files
③执行编译
1
    senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$ ./build_platform.sh

报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    Export includes file: frameworks/opt/emoji/Android.mk -- out/target/product/generic/obj/SHARED_LIBRARIES/libemoji_intermediates/export_includes
    Export includes file: external/harfbuzz/Android.mk -- out/target/product/generic/obj/SHARED_LIBRARIES/libharfbuzz_intermediates/export_includes
    Export includes file: external/webkit/Android.mk -- out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/export_includes
    Export includes file: external/libxml2/Android.mk -- out/target/product/generic/obj/STATIC_LIBRARIES/libxml2_intermediates/export_includes
    Export includes file: external/libxslt/Android.mk -- out/target/product/generic/obj/STATIC_LIBRARIES/libxslt_intermediates/export_includes
    Export includes file: external/hyphenation/Android.mk -- out/target/product/generic/obj/STATIC_LIBRARIES/libhyphenation_intermediates/export_includes
    Import includes file: out/target/product/generic/obj/SHARED_LIBRARIES/libemoji_intermediates/import_includes
    Import includes file: out/target/product/generic/obj/SHARED_LIBRARIES/libharfbuzz_intermediates/import_includes
    target Generated: libwebcore <= external/webkit/Source/WebCore/html/DocTypeStrings.gperf
    Generating HTMLEntityTable.cpp
    target Generated: libwebcore <= external/webkit/Source/WebCore/platform/ColorData.gperf
    WebCore Yacc: libwebcore <= external/webkit/Source/WebCore/css/CSSGrammar.y
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    WebCore Yacc: libwebcore <= external/webkit/Source/WebCore/xml/XPathGrammar.y
    target Generated: libwebcore <= external/webkit/Source/WebCore/dom/make_names.pl
    Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
    BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
    Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
    BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
    make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] 错误 2
    make: *** 正在等待未完成的任务....
    make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/platform/ColorData.cpp] 错误 2
    target Generated: libwebcore <= external/webkit/Source/WebCore/html/parser/HTMLEntityNames.in
    senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$ ./build_platform.sh

在core.mk里把 libwebcore \删掉,再build,报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    Install: out/target/product/generic/system/fonts/NotoSansKhmerUI-Bold.ttf
    Install: out/target/product/generic/system/fonts/NotoSansKhmerUI-Regular.ttf
    Install: out/target/product/generic/system/fonts/NotoSansLao-Bold.ttf
    Install: out/target/product/generic/system/fonts/NotoSansLao-Regular.ttf
    Install: out/target/product/generic/system/fonts/NotoSansLaoUI-Bold.ttf
    Install: out/target/product/generic/system/fonts/NotoSansLaoUI-Regular.ttf
    Install: out/target/product/generic/system/fonts/NotoSansMalayalam-Bold.ttf
    collect2: error: ld returned 1 exit status
    Install: out/target/product/generic/system/fonts/NotoSansMalayalam-Regular.ttf
    make: *** [out/target/product/generic/obj/EXECUTABLES/dnsmasq_intermediates/LINKED/dnsmasq] 错误 1
    make: *** 正在等待未完成的任务....
    Install: out/target/product/generic/system/fonts/NotoSansMalayalamUI-Bold.ttf
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:339: error: undefined reference to 'ext2fs_test_bit64'
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:390: error: undefined reference to 'ext2fs_test_bit64'
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:186: error: undefined reference to 'ext2fs_test_bit64'
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:281: error: undefined reference to 'ext2fs_mem_is_zero'
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:178: error: undefined reference to 'ext2fs_clear_bit64'
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:170: error: undefined reference to 'ext2fs_set_bit64'
    external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:141: error: undefined reference to 'ext2fs_clear_bit64'
    external/e2fsprogs/lib/ext2fs/gen_bitmap64.c:735: error: undefined reference to 'ext2fs_get_bitmap_granularity'
    external/e2fsprogs/lib/ext2fs/gen_bitmap64.c:790: error: undefined reference to 'ext2fs_find_first_zero_generic_bitmap'
    external/e2fsprogs/lib/ext2fs/mmp.c:57: error: undefined reference to 'ext2fs_get_dio_alignment'
    external/e2fsprogs/lib/ext2fs/mmp.c:213: error: undefined reference to 'ext2fs_alloc_block2'
    collect2: error: ld returned 1 exit status
    make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libext2fs_intermediates/LINKED/libext2fs.so] 错误 1
    senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$

再把 libexifa \删掉,报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/blkmap64_ba.o: In function `ba_find_first_zero':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:339: undefined reference to `ext2fs_test_bit64'
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:390: undefined reference to `ext2fs_test_bit64'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/blkmap64_ba.o: In function `ba_test_bmap':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:186: undefined reference to `ext2fs_test_bit64'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/blkmap64_ba.o: In function `ba_test_clear_bmap_extent':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:281: undefined reference to `ext2fs_mem_is_zero'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/blkmap64_ba.o: In function `ba_unmark_bmap':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:178: undefined reference to `ext2fs_clear_bit64'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/blkmap64_ba.o: In function `ba_mark_bmap':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:170: undefined reference to `ext2fs_set_bit64'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/blkmap64_ba.o: In function `ba_resize_bmap':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/blkmap64_ba.c:141: undefined reference to `ext2fs_clear_bit64'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/gen_bitmap64.o: In function `ext2fs_convert_subcluster_bitmap':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/gen_bitmap64.c:735: undefined reference to `ext2fs_get_bitmap_granularity'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/gen_bitmap64.o: In function `ext2fs_find_first_zero_generic_bmap':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/gen_bitmap64.c:790: undefined reference to `ext2fs_find_first_zero_generic_bitmap'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/mmp.o: In function `ext2fs_mmp_read':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/mmp.c:57: undefined reference to `ext2fs_get_dio_alignment'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/mmp.o: In function `ext2fs_mmp_init':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/mmp.c:213: undefined reference to `ext2fs_alloc_block2'
    collect2: ld returned 1 exit status
    make: *** [out/host/linux-x86/obj/lib/libext2fs_host.so] 错误 1
    make: *** 正在等待未完成的任务....
    1 warning generated.
    external/openssl/ssl/s2_clnt.c:1027:38: warning: unused parameter 'type' [-Wunused-parameter]
    int ssl2_set_certificate(SSL *s, int type, int len, const unsigned char *data)
                                         ^
    1 warning generated.
    external/openssl/ssl/s2_lib.c:385:38: warning: unused parameter 'larg' [-Wunused-parameter]
    long ssl2_ctrl(SSL *s, int cmd, long larg, void *parg)
                                         ^
    external/openssl/ssl/s2_lib.c:385:50: warning: unused parameter 'parg' [-Wunused-parameter]
    long ssl2_ctrl(SSL *s, int cmd, long larg, void *parg)
                                                     ^
    external/openssl/ssl/s2_lib.c:400:30: warning: unused parameter 's' [-Wunused-parameter]
    long ssl2_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
                                 ^
    external/openssl/ssl/s2_lib.c:400:37: warning: unused parameter 'cmd' [-Wunused-parameter]
    long ssl2_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
                                        ^
    external/openssl/ssl/s2_lib.c:400:49: warning: unused parameter 'fp' [-Wunused-parameter]
    long ssl2_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
                                                    ^
    external/openssl/ssl/s2_lib.c:405:29: warning: unused parameter 'ctx' [-Wunused-parameter]
    long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
                                ^
    external/openssl/ssl/s2_lib.c:405:38: warning: unused parameter 'cmd' [-Wunused-parameter]
    long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
                                         ^
    external/openssl/ssl/s2_lib.c:405:48: warning: unused parameter 'larg' [-Wunused-parameter]
    long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
                                                   ^
    external/openssl/ssl/s2_lib.c:405:60: warning: unused parameter 'parg' [-Wunused-parameter]
    long ssl2_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
                                                               ^
    external/openssl/ssl/s2_lib.c:410:38: warning: unused parameter 'ctx' [-Wunused-parameter]
    long ssl2_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
                                         ^
    external/openssl/ssl/s2_lib.c:410:47: warning: unused parameter 'cmd' [-Wunused-parameter]
    long ssl2_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
                                                  ^
    external/openssl/ssl/s2_lib.c:410:59: warning: unused parameter 'fp' [-Wunused-parameter]
    long ssl2_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
                                                              ^
    12 warnings generated.
    1 warning generated.
    make: *** wait: 没有子进程。 停止。
    senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY$

然后把之前的core.mk第二部分替换成README里的,报错

1
2
3
4
5
6
7
8
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/mmp.c:57: undefined reference to `ext2fs_get_dio_alignment'
    out/host/linux-x86/obj/SHARED_LIBRARIES/libext2fs_host_intermediates/mmp.o: In function `ext2fs_mmp_init':
    /home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/mmp.c:213: undefined reference to `ext2fs_alloc_block2'
    collect2: ld returned 1 exit status
    make: *** [out/host/linux-x86/obj/lib/libext2fs_host.so] 错误 1
    make: *** 正在等待未完成的任务....
    Processing target/product/generic/dex_bootjars/system/framework/core.jar
    Done!

然后把core.mk里第二部分全都删掉,报的错还是上面那个。

恢复下core.mk重来,

报1:报错external/webkit/Source/WebCore/make-hash-tools.pl line 23.,core.mk砍掉 libwebcore \ 代码砍掉external/webkit.

报2:/home/senrsl/android/source/WORKING_DIRECTORY/external/e2fsprogs/lib/ext2fs/mmp.c:213: undefined reference to `ext2fs_alloc_block2',external/e2fsprogs 代码换回原版。

报3:/home/senrsl/android/source/WORKING_DIRECTORY/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/../lib/gcc/arm-linux-androideabi/4.7/../../../../arm-linux-androideabi/bin/ld: error: out/target/product/generic/obj/EXECUTABLES/dnsmasq_intermediates/dhcp-common.o: multiple definition of ‘option_string’ /home/senrsl/android/source/WORKING_DIRECTORY/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/../lib/gcc/arm-linux-androideabi/4.7/../../../../arm-linux-androideabi/bin/ld: out/target/product/generic/obj/EXECUTABLES/dnsmasq_intermediates/option.o: previous definition here,external/dnsmasq换回原版。

然后编译

这样竟编译成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    Creating filesystem with parameters:
        Size: 576716800
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 7040
        Inode size: 256
        Journal blocks: 2200
        Label:
        Blocks: 140800
        Block groups: 5
        Reserved block group size: 39
    Created filesystem with 892/35200 inodes and 65272/140800 blocks
    + '[' 0 -ne 0 ']'
    Install system fs image: out/target/product/generic/system.img
    out/target/product/generic/system.img+ maxsize=588791808 blocksize=2112 total=576716800 reserve=5947392

镜像文件输出到了/home/senrsl/android/source/WORKING_DIRECTORY/out/target /product/generic

4)封包

查看下官方提供的E300LKLUFNE4_E300LLGTFNE4_E300LKLUFNC1_HOME.tar

依次罗列了这几个img.

尝试封装

1
2
3
4
5
    senrsl@senrsl-ubuntu:~/android/source/WORKING_DIRECTORY/out/target/product/generic$ tar cvf p.tar cache.img ramdisk.img system.img userdata.img
    cache.img
    ramdisk.img
    system.img
    userdata.img

然后重启系统去烧。

//TODO 未成功,无法烧入


I9507V 的external/e2fsprogs,external/dnsmasq换回原版,就能编译成功,没试过烧进真机。