Archive for the ‘Android’ Category

How to Compile Samsung GT-S5360’s Kernel on Windows OS

September 4, 2017

The sources uses for this article is this one:

https://github.com/percy-g2/GNU-kernel

But later on, this proves to be useless, as you can see near the end of this article

This is downloaded and placed in D:\Projects\AndroidKernel\Samsung\kernel

Rooting the device using:

https://forum.xda-developers.com/showthread.php?t=2085390

Install required Samsung USB driver SAMSUNG_USB_Driver_for_Mobile_Phones.zip.

First perform some file study on the ramdisk structure of existing device by transferring files from device to PC:

C:\Android\sdk\platform-tools>adb pull init.rc d:\z
adb: error: failed to copy ‘init.rc’ to ‘d:\z\init.rc’: remote Permission denied

So, it is a remote Permission denied. Let’s leave it for a while.

Install CWM to the device:

C:\Android\sdk\platform-tools>adb push D:\Projects\AndroidKernel\Samsung\cwm.zip
/sdcard
D:\Projects\AndroidKernel\Samsung\cwm….ed. 4.8 MB/s (1418804 bytes in 0.281s)

Install CWM and perform back up.

Later on, when I restart the phone, I’ve found that ADB functionality is disabled, which means that when I plug the USB cable to my PC, the phone only reacted with charging only.

After performing the factory reset, the ADB functionality is come back as expected. So I decided to investigate further.

When I connect the phone using USB cable, the device is registered as BCM21553-Thunderbird.

A question to my mind: does the driver is coming from Samsung USB driver I installed earlier, or is it coming from the phone itself ?

I unplugged the phone, and perform uninstall of the USB driver. There’s no Samsung driver now, I plug the USB cable. It registered as BCM21553-Thunderbird, and ready to use but the ADB command can not detect the device.

So, unplug, and re-install the USB driver, and re-plug, and see what happens now.

It tries to install the driver, and when I skip the windows update, the installation process brings out status as follows:

So, the Samsung USB driver is indeed required for ADB functionality. Now, let’s try to disable USB debugging in the phone and see what happens.

It reverts to USB storage. When I enable USB debugging and USB storage through the phone menu, both the ADB and file system in my PC can detect the files. Hmm, great !

So, what causes the failure in the ADB functionality ? Is it because I install CWM.zip recovery image ?

Unplug and re-install CWM (ClockworkMod Recovery v5.0.2.6) recovery, then perform re-boot, and see what happens. The ADB still detect the device. Hmm, strange. Maybe there are extra steps that I’ve done in recovery program that causes this. But let’s leave this for the moment.

Let’s empty the SD card leaving only update.zip (for rooting) and CWM.zip for recovery.

Unplug, entering to recovery mode and install CWM again. This time, I try to perform backup and see what files that gets created. One of interesting file is boot.img. Let’s examine it.

The carliv image kitchen failed to recognize this file, turns out the boot.img contains nothing only a series of 0xFF from start to the end of file.

The boot.img is important because it will be used as base line for the compiled kernel source. So, I have some options as follows: try to examine the CWM recovery source file or try to get the stock rom.

I decided to use custom rom for GT-S5360 from this site:

http://www.droidthunder.com/update-samsung-galaxy-y-s5360-to-android-5-0-lollipop/

By following the exact step, I get the working Android Lollipop themed on my Samsung GT-S5360 phone, with also a working USB storage and debugging for ADB command purposes.

Next, I try to identify objects inside the custom kernel’s (kernel_CM7_v4.0_totoro.zip) boot.img to find out what will be the requirements to get a workable kernel image.

D:\Projects\AndroidKernel\Samsung\carliv>carliv

This time carliv image kitchen works, and examining the result, the boot.image consists of the kernel and ramdisk.

Checking the root structure of the system verifies that it is indeed from ramdisk:

C:\Android\sdk\platform-tools>adb she
$ su
# ls -a
efs
config
cache
sd-ext
sdcard
acct
mnt
vendor
d
etc
ueventd.rc
ueventd.goldfish.rc
tmp
system
sys
sbin
res
recovery.rc
proc
lib
init.rc
init.goldfish.rc
init.charge.rc
init.bcm21553.rc
init
fota.rc
default.prop
data
root
dev
#
# pwd
/
#

Let’s check the log files whether it is exist, this is done by perform all backup to the sdcard, copying content to the PC for ease of searching and investigating. Searching for *log* yield no result whatsoever.

Try to search using *.txt find some interesting file called SYSTEM_BOOT@1293963501309.txt with content as follows:

Build: samsung/GT-S5360/GT-S5360:2.3.6/GINGERBREAD/XWKTN:user/release-keys
Hardware: totoro
Bootloader: unknown
Radio: unknown
Kernel: Linux version 2.6.35.7 (bieltv3@bieltv3) (gcc version 4.4.3 (GCC) ) #32 PREEMPT Fri Feb 14 16:33:03 CET 2014

From recovery_kernel_log.txt on back up of original ROM I also get information about the machine:

[ 0.000000] Machine: BCM21553 ThunderbirdEDN31 platform

Try to get more information about the kernel based on the above string information proves to be very difficult and vague, but later on, I’ve found that dmesg is useful to get kernel messages for this ROM.

In the adb shell:

$ su
# dmesg > sdcard/mymsg.txt

Then:

C:\Android\sdk\platform-tools>adb pull /sdcard/mymsg.txt d:\z
/sdcard/mymsg.txt: 1 file pulled. 5.4 MB/s (89066 bytes in 0.016s)

Let’s perform some queries of this Samsung devices:

# ls -s /proc
total 0
0 rfs
0 LinuStoreIII

# cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 5 (v6l)
BogoMIPS : 832.90
Features : swp half thumb fastmult vfp edsp java
CPU implementer : 0x41
CPU architecture: 6TEJ
CPU variant : 0x1
CPU part : 0xb36
CPU revision : 5

Hardware : BCM21553 ThunderbirdEDN31 platform
Revision : 0000
Serial : 0000000000000000

# cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
7 vcs
10 misc
13 input
29 fb
89 i2c
90 mtd
108 ppp
116 alsa
128 ptm
136 pts
151 gememalloc
199 bcm_gps
200 bcm_cntin
201 bcm_kril
202 bcm_log
203 bcm_atc
204 bcm_fuse_ipc
205 bcm_rpc
206 bcm_alsa_pcg
207 bcm_audio_log
208 bcm_vsp
209 bcm_alsa_voip
210 hx170dec
211 h6270enc
212 bcm_kpdp
216 rfcomm
230 memalloc
243 lcd
246 camera
250 BrcmHeadset
251 v3d
252 ttyGS
253 cache-ops
254 rtc

Block devices:
1 ramdisk
259 blkext
7 loop
31 mtdblock
137 bml
138 stl
179 mmc
254 device-mapper
#

To verify the start up codes against the downloaded source, let’s extract the boot.img.

At the end of the boot process routines, I expected to find 0x1F and 0x8B for gzip signature, but I found none. It has 0x5D as the signature, and at the end of the kernel binary, there’s an interesting string: bad header. So, based on sources searching, it is found that this error message is uniquely found in D:\Projects\AndroidKernel\Samsung\kernel\common\lib\decompress_unlzma.c.

For a verification, I dissected the binary portion and placed it in test.lzma file using WinHex and try to decompress with 7-zip without any incidence.

Next, I try to load the extracted kernel into IDA Dissasembler to examine the routine and compared it with D:\Projects\AndroidKernel\Samsung\kernel\common\arch\arm\boot\compressed\head.S from downloaded kernel source.

The first statements until SVC 0x123456 is still consistent with the source code. But after instruction MSR CPSR_c, R2 there are two mysterious statement which consists of ANDEQ R0, R0, R0 twice, which is actually 0x00 bytes of 8 bytes size.

But later on, upon close examination, it is maybe inserted by the linker, as evidenced from comment of head.s source code: some architecture specific code can be inserted by the linker here, but it should preserve r7, r8, and r9 …

Statement after this is consistent. The downloaded source looks promising. So, let’s prepare for the compilation process.

Let’s test the basic logic of the make file:

D:\Projects\AndroidKernel\Samsung\kernel\common>make
make: /home/percy/sgy/arm-2009q3/bin/arm-none-eabi-gcc: Command not found
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:116:23: fatal error: arpa/inet.h: No such file or directo
ry
compilation terminated.
make[2]: *** [scripts/basic/fixdep] Error 1
make[1]: *** [scripts_basic] Error 2
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

So, let’s try:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-none-androideabi-
make: C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-none-
androideabi-gcc: Command not found
make -f /d/Projects/AndroidKernel/Samsung/kernel/common/Makefile silentoldconfig

make -f scripts/Makefile.build obj=scripts/basic
gcc -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wmissing-prototypes -Wstrict-protot
ypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.c

scripts/basic/fixdep.c:116:23: fatal error: arpa/inet.h: No such file or directo
ry
compilation terminated.

Perform changes in the make file:

HOSTCC:=i686-pc-cygwin-gcc-4

Now I have:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-none-androideabi-
make: C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-none-
androideabi-gcc: Command not found
make -f /d/Projects/AndroidKernel/Samsung/kernel/common/Makefile silentoldconfig

make -f scripts/Makefile.build obj=scripts/basic
i686-pc-cygwin-gcc-4 -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wmissing-prototype
s -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scrip
ts/basic/fixdep.c
scripts/basic/fixdep.c: In function `parse_config_file’:
scripts/basic/fixdep.c:242:4: warning: array subscript has type `char’
scripts/basic/fixdep.c: In function `parse_dep_file’:
scripts/basic/fixdep.c:323:4: warning: array subscript has type `char’
scripts/basic/fixdep: scripts/basic/fixdep: cannot execute binary file
make[2]: *** [scripts/basic/fixdep] Error 126
make[1]: *** [scripts_basic] Error 2
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

Checking the files in location D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\basic reveals there’s a fixdep file in ELF format. Remove it and the error is gone, but I have a crashed windows, hmm, interesting πŸ™‚

But let’s focus to this error:

make: C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-none-
androideabi-gcc: Command not found

This is because the current NDK does not have arm-none-androideabi-gcc.exe binary. So, let’s change it to arm-linux-androideabi-gcc, which causes windows crashing as in previous incident:

To solve this problem, let’s use info command. Starting by:

$(info verbose is $(KBUILD_VERBOSE))

To check whether the script is already set to verbose mode, and the result is yes, it is already verbose. But still, there’s no verbose information leading to the clue to the cause of crashing.

After spending considerable time I’ve found the location of the cause of crashing is from D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\Kbuild.include:

try-run = $(shell set -e; \
TMP=”$(TMPOUT).$$$$.tmp”; \
TMPO=”$(TMPOUT).$$$$.o”; \
if ($(1)) >/dev/null 2>&1; \
then echo “$(2)”; \
else echo “$(3)”; \
fi; \
rm -f “$$TMP” “$$TMPO”)

Revise the above script into:

MYTMP:=$$$$.tmp
MYTMPO:=$$$$.o
try-run = $(shell set -e; \
if ($(1)) >/dev/null 2>&1; \
then echo “$(2)”; \
else echo “$(3)”; \
fi; \
rm -f $(MYTMP) $(MYTMPO))

And change all the successive call to try-run using the above construct, for example:

cc-ldoption = $(call try-run,\
$(CC) $(1) -nostdlib -xc /dev/null -o “$$TMP”,$(1),$(2))

Become:

cc-ldoption = $(call try-run,\
$(CC) $(1) -nostdlib -xc /dev/null -o $(MYTMP),$(1),$(2))

Will solve the above initial crash problem.

Now I have not only crashing windows but also my command prompt gone by itself. Hmm, intriguing πŸ™‚

After spending some time investigating this issue, the causes turns out to be trivial, i.e. there’s again some ELF file in the downloaded kernel that cause confusion in the OS.

Now I have:


scripts/kconfig/menu.c: In function `menu_add_prop’:
scripts/kconfig/menu.c:134:3: warning: array subscript has type `char’
scripts/kconfig/menu.c:136:4: warning: array subscript has type `char’
scripts/kconfig/conf: scripts/kconfig/conf: cannot execute binary file

Again I still have some windows crashes like the picture below:

But this time, after all of the issue of lingering ELF file already solved. And when I press the “Close the program”, my console window is gone also, and I have to start over and type the path to the kernel source location. This kind of error will cause a great sorrow and very discouraging.

I realized this is caused by the using of make command. So when I use this command line:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-linux-androideabi-

The windows will crashes.

But using this one, by adding -p option for make debugging traces, there’s no crash:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-linux-androideabi- -p > myTesting.txt

Maybe this is caused by the Cygwin compiler behaviour. And because the host command application already created, there’s no reason to keep creating it each time when doing the compilation process, so let’s remark this make script portion in D:\Projects\AndroidKernel\Samsung\kernel\common\Makefile:

#PHONY += scripts_basic
#scripts_basic:
# $(Q)$(MAKE) $(build)=scripts/basic
# $(Q)rm -f .tmp_quiet_recordmcount

The crash is gone, but now I have:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-linux-androideabi-
build image is zImage
make -f /d/Projects/AndroidKernel/Samsung/kernel/common/Makefile silentoldconfig

make[1]: *** No rule to make target `silentoldconfig’. Stop.
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

There are new target error here, so, let’s create a dummy target for script_basic:

PHONY += scripts_basic
scripts_basic:
@echo “Script Basic”

Now again I get crash, which is caused by another call to cygwin compiler. So, make combined with cygwin compiler will cause windows crash, but can be remedied by using -p options.

I decided to investigate it further, of why the exact nature of the crashing windows when it is using without -p options.

After spending some considerable time, I found the source of the problem, which is the present of extra hyphen or minus in one of the compiler checking script.

The script in question is located at D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\kconfig\check.sh, which contains:

Please pay a close attention to the above script. I’ve marked the extra hyphen or minus sign in that script. And by removing that extra hyphen and try to call make again without -p option, the windows crashing is now gone, for a moment.

By perform global text searching, this kind of construct is also located in D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\kconfig\lxdialog\check-lxdialog.sh. So, to prevent another frustration, it is also fixed.

This makes me wonder, why in Linux OS system do not crash, or is it some form of preventive measure from Linux community to thwart the Windows OS to get a successful compile ? Hmm, anyway it is an interesting phenomena.

Now I have:


arch/arm/Kconfig:1138: can’t open file “drivers/pci/Kconfig”
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

First error:

arch/arm/Kconfig:1138: can’t open file “drivers/pci/Kconfig”

Can be resolved by create a blank Kconfig file in D:\Projects\AndroidKernel\Samsung\kernel\common\drivers\pci

Same for:

arch/arm/Kconfig:1140: can’t open file “drivers/pcmcia/Kconfig”
arch/arm/Kconfig:1632: can’t open file “drivers/cpuidle/Kconfig”
net/Kconfig:211: can’t open file “drivers/net/appletalk/Kconfig”

And after several hundreds of this kind of replacement, I came at:

make[1]: `include/generated/mach-types.h’ is up to date.
make -f scripts/Makefile.build obj=.
(cat /dev/null; ) > modules.order
./scripts/basic/hash: ./scripts/basic/hash: cannot execute binary file
./scripts/basic/hash: ./scripts/basic/hash: cannot execute binary file

fixdep:
: No such file or directory
make[1]: *** [kernel/bounds.s] Error 2
make: *** [prepare0] Error 2

Again the lingering ELF file for hash. Let’s try again after removing it.

The fixdep still has error. And based on my previous post about compiling goldfish kernel, there should be some small changes in the source file, so by copying it into this folder and re-compile fixdep, I have:

i686-pc-cygwin-gcc-4 -Wp,-MD,scripts/mod/.mk_elfconfig.d -Wall -Wmissing-proto
types -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/mod/mk_elfconf
ig scripts/mod/mk_elfconfig.c
scripts/mod/mk_elfconfig scripts/mod/elfconfig.h
scripts/mod/mk_elfconfig: scripts/mod/mk_elfconfig: cannot execute binary file
make[2]: *** [scripts/mod/elfconfig.h] Error 126
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2

Oh boy, another lingering ELF, I suppose. Remove, and this time, I have another windows crashing.

Again after spending some time checking for this issue, it is found that this construct in D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\mod\Makefile:

The green one which the original one will cause windows to crash. Apparently, simultaneously redirecting input and output can’t be handled by windows at this time.

So I have to modify it without output redirection, but using routines inside D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\mod\mk_elfconfig.c to create the required output file.

Now I have:


usr/gen_init_cpio: usr/gen_init_cpio: cannot execute binary file
make[1]: *** [usr/initramfs_data.cpio] Error 126
make: *** [usr] Error 2

Remove the offending ELF file, after some compilation time, I have:

Let’s try:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm bcm21553_totor
o_02B0_defconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebu
ilt/windows/bin/arm-linux-androideabi-

Then:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError1.txt

Checking on the result file:

In file included from arch/arm/plat-bcmap/include/plat/gpio.h:22:0,
from arch/arm/mach-bcm215xx/include/mach/gpio.h:16,
from d:/Projects/AndroidKernel/Samsung/kernel/common/arch/arm/include/asm/gpio.h:5,
from include/linux/gpio.h:7,
from arch/arm/mach-bcm215xx/include/mach/setup.h:24,
from arch/arm/mach-bcm215xx/board-totoro.c:36:
include/asm-generic/gpio.h: In function ‘gpio_get_value_cansleep’:
include/asm-generic/gpio.h:206:2: error: implicit declaration of function ‘gpio_get_value’ [-Werror=implicit-function-declaration]
return gpio_get_value(gpio);

Let’s try again with:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm bcm21553_totor
o_02B0_defconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebu
ilt/windows/bin/arm-linux-androideabi-

Then:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError2.txt

But I still have:


In file included from arch/arm/plat-bcmap/include/plat/gpio.h:22:0,
from arch/arm/mach-bcm215xx/include/mach/gpio.h:16,
from d:/Projects/AndroidKernel/Samsung/kernel/common/arch/arm/include/asm/gpio.h:5,
from include/linux/gpio.h:7,
from arch/arm/mach-bcm215xx/include/mach/setup.h:24,
from arch/arm/mach-bcm215xx/board-totoro.c:36:
include/asm-generic/gpio.h: In function ‘gpio_get_value_cansleep’:
include/asm-generic/gpio.h:206:2: error: implicit declaration of function ‘gpio_get_value’ [-Werror=implicit-function-declaration]
return gpio_get_value(gpio);

No matter what combination of possible configs that I throw to the compiler, the result is always the same.

So, I decided to use the default auto.conf from original Percy’s github and copied to D:\Projects\AndroidKernel\Samsung\kernel\common\include\config\auto.conf.

Then I have to disable the conf.exe by modifying the source in D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\kconfig\conf.c from action by just returning to the caller, so that the auto.conf do not get modified:

But this time I have:


init/do_mounts_rd.c: At top level:
init/do_mounts_rd.c:158:12: error: redefinition of ‘rd_load_image’
int __init rd_load_image(char *from)

Upon close examination, the cause of the above error is undefined variable called CONFIG_BLK_DEV_RAM in D:\Projects\AndroidKernel\Samsung\kernel\common\init\do_mounts.h, which causes compilation process goes to the else block:

By checking the parameter passed to the compiler, it is realized that this variable depends on D:\Projects\AndroidKernel\Samsung\kernel\common\include\generated\autoconf.h for the above definition.

Let’s copy this file content from the original github location to this one, and the previous compiler error at board-totoro.c is now gone, and after a significant progress in compiling process that takes considerable time, I have:


make -f scripts/Makefile.build obj=drivers
make -f scripts/Makefile.build obj=drivers/auxdisplay
scripts/Makefile.build:44: /d/Projects/AndroidKernel/Samsung/kernel/common/drive
rs/auxdisplay/Makefile: No such file or directory
make[2]: *** No rule to make target `/d/Projects/AndroidKernel/Samsung/kernel/co
mmon/drivers/auxdisplay/Makefile’. Stop.
make[1]: *** [drivers/auxdisplay] Error 2

Let’s try to use drivers inside:

https://github.com/broadcomCM/android_kernel_samsung_bcm21553-common

And copy the content of drivers into D:\Projects\AndroidKernel\Samsung\kernel\common\drivers. Re-compile, and I have:


scripts/conmakehash: scripts/conmakehash: cannot execute binary file
make[2]: *** [drivers/char/consolemap_deftbl.c] Error 126
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2

Delete the offending ELF file and after compiling process of considerable time, there’s an error, but the my windows console do not keep the earliest error location. So I have to recompile using this option:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError.txt

This wlll trap any error into the file for further analysis.

And here is the earliest compiler error message:


drivers/staging/android/lowmemorykiller.c: In function ‘lowmem_shrink’:
drivers/staging/android/lowmemorykiller.c:275:27: error: ‘TIF_MM_RELEASED’ undeclared (first use in this function)

Checking to the source makes me question the validity of the copied folder from broadcomCM’s github source. So, I try to retrieve lowmemorykiller.c from:

https://android.googlesource.com/kernel/samsung/+/android-samsung-2.6.35-gingerbread/drivers

And it compiles without any error.

This lead me to replace the entire drivers folder by this one, to see what happens:


drivers/mmc/card/block.c: In function ‘mmc_blk_issue_rq’:
drivers/mmc/card/block.c:387:6: error: implicit declaration of function ‘mmc_card_adjust_cfg’ [-Werror=implicit-function-declaration]
mmc_card_adjust_cfg(card->host, READ);

Let’s revert back the drivers from broadcomCM, but this time, replace lowmemorykiller.c from android-samsung-2.6.35-gingerbread.

Now I have:

In file included from drivers/staging/bcm21553/drivers/char/brcm/fuse_at/atc_kernel.c:58:0:
drivers/staging/bcm21553/drivers/char/brcm/fuse_rpc/rpc_CIB/public/rpc_ipc.h:138:22: error: ‘IPC_PROPERTY_START_AP’ undeclared here (not in a function)
RPC_PROP_START_AP = IPC_PROPERTY_START_AP, ///make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- d
rivers/staging/bcm21553/drivers/char/brcm/fuse_at/atc_kernel.o

Copy IPCProperties.h from broadcomCM github source to D:\Projects\AndroidKernel\Samsung\kernel\common\include\linux\broadcom\IPCProperties.h.

Perform quick re-compiling by invoking the above message, and although there are many warnings, the compiler managed to create atc_kernel.o.

Now, let’s perform a long compile again:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError.txt

And I have:


drivers/staging/bcm21553/drivers/video/bmem/bmem.c:165:5: error: unknown field ‘GetFreeMemorySize’ specified in initializer
.GetFreeMemorySize = bmem_GetFreeMemorySize,

Copy the file to D:\Projects\AndroidKernel\Samsung\kernel\common\include\linux\broadcom\bmem_wrapper.h. And verify again by quick compiling, it is a success again.

So, copy the entire folder from broadcomCM github to D:\Projects\AndroidKernel\Samsung\kernel\common\include\linux\broadcom folder.

Now I have:


drivers/video/fbmem.c: In function ‘fb_mmap’:
drivers/video/fbmem.c:1360:2: error: implicit declaration of function ‘vm_iomap_memory’ [-Werror=implicit-function-declaration]
return vm_iomap_memory(vma, start, len);

Copy this file from broadcomCM github to:

D:\Projects\AndroidKernel\Samsung\kernel\include\linux\mm.h
D:\Projects\AndroidKernel\Samsung\kernel\mm\memory.c

Quick compile is a success now, let’s do long compile again. And we have:


mm/memory.c: In function ‘unmap_mapping_range’:
mm/memory.c:2679:21: error: ‘struct address_space’ has no member named ‘unmap_mutex’
mutex_lock(&mapping->unmap_mutex);

Replace:

D:\Projects\AndroidKernel\Samsung\kernel\fs\inode.c
D:\Projects\AndroidKernel\Samsung\kernel\include\linux\fs.h

And I have:

mm/mlock.c: At top level:
mm/mlock.c:139:19: error: redefinition of ‘vma_stack_continue’
static inline int vma_stack_continue(struct vm_area_struct *vma, unsigned long addr)

At this point, I believe this kind of compiler error will not be resolved till the end of time πŸ™‚

So, I decided to get a kernel source tree version check, and I’ve found:

The one I try to compiled that do not have complete drivers folder, which cause drivers/auxdisplay make error:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- k
ernelversion
2.6.35.7

The one from broadcomCM github that has the complete driver folder:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 CROSS_COMPILE=C:/NDK/toolchai
ns/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- kernelv
ersion
2.6.35.14

Let’s switch to the kernel from broadcomCM, and let’s see how far it can go with the compiling process. To do this, I’ve prepared the source base in:

D:\Projects\AndroidKernel\Samsung\kernel2

But copy the configuration info from the kernel I’ve try to compile and bypass the conf.exe checking, using tricks I’ve described above. This is necessary so that the auto.conf, .config and autoconf.h is intact without get modified by conf.exe. Also perform some necessary script revision and program patches as described above, then let’s compile:


drivers/built-in.o:silabs_f760_totoro.c:function silabs_ts_probe: error: undefin
ed reference to ‘Synaptics_Connected’
drivers/built-in.o:silabs_f760_totoro.c:function silabs_ts_init: error: undefine
d reference to ‘Synaptics_Connected’
make: *** [.tmp_vmlinux1] Error 1

This puts configuration data from percy-g2 into question. Let’s use another configuration by using this command. But first, I have to enable the conf.c to process the Kconfig to generate auto.conf instead of bypassing it.

Then use this configuration:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 ARCH=arm bcm21553_totoro_05_d
efconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/wind
ows/bin/arm-linux-androideabi-

After that, perform re-compiling, but I have:


c:\NDK\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: error: arch/arm/boot/compressed/piggy.gzip.o: unknown CPU architecture
c:\NDK\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: error: arch/arm/boot/compressed/lib1funcs.o: unknown CPU architecture
make[2]: *** [arch/arm/boot/compressed/vmlinux] Error 1

This is the classic error and already resolved in my previous article about how to compile goldfish kernel, i.e by manually compiling the offending lib1funcs.S by deleting the -march=all switch.

Now, to get the information of the last steps that should be manually taken for creating the boot kernel, I have to re-compile using -p switch again.

These three should be compiled manually without -march=all option (piggy.gzip.S, head.S and lib1funcs.S):

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.lib1funcs.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideabi
-4.8\prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Proj
ects\AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include\
generated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\inclu
de -Iarch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-int
erwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s –
include asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\compre
ssed\lib1funcs.o arch\arm\boot\compressed\lib1funcs.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.head.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideabi-4.8\
prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Projects\
AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include\gener
ated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\include -I
arch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwor
k -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s -inclu
de asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\compressed\
head.o arch\arm\boot\compressed\head.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.piggy.gzip.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Pro
jects\AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include
\generated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\incl
ude -Iarch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-in
terwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s
-include asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\comp
ressed\piggy.gzip.o arch\arm\boot\compressed\piggy.gzip.S

Then for final steps:

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld -EL –defsym zreladdr=0x8160
0000+0x8000 -p –no-undefined -X -T arch\arm\boot\compressed\vmlinux.lds arch\ar
m\boot\compressed\head.o arch\arm\boot\compressed\piggy.gzip.o arch\arm\boot\com
pressed\misc.o arch\arm\boot\compressed\decompress.o arch\arm\boot\compressed\li
b1funcs.o -o arch\arm\boot\compressed\vmlinux

And:

D:\Projects\AndroidKernel\Samsung\kernel2>C:/NDK/toolchains/arm-linux-androideab
i-4.8/prebuilt/windows/bin/arm-linux-androideabi-objcopy -O binary -R .note -R .
note.gnu.build-id -R .comment -S arch/arm/boot/compressed/vmlinux arch/arm/boot/
zImage

This image is the kernel and can be used to create boot.img using carliv image kitchen.

Advertisements

From boot.img to boot.img-dt to DTB and DTS in Windows OS

August 16, 2017

Uncompress boot.img using carliv_image_kitchen-v1.3-x86.zip:

Then execute this command in cmd:

D:\Projects\AndromaxQ\carliv>carliv

Executing carliv and we have boot.img-dt. Let’s see whether the utility called dtc can be use to decode this file.

The dtc utility should be compiled first from: D:\Projects\dtc. So, let’s compile:

D:\Projects\dtc>make
CHK version_gen.h
CC convert-dtsv0-lexer.lex.o
convert-dtsv0-lexer.l:42:21: fatal error: fnmatch.h: No such file or directory
compilation terminated.
make: *** [convert-dtsv0-lexer.lex.o] Error 1

To capture what command that causes this error, it is necessary to use procmon.exe, using this settings:

And then export to a command line using batch file.

After examining more closely, the causes is that MINGW is not supporting the fnmatch function, so it should use Cygwin’s compiler instead. This is done by changing CC variable in makefile:

CC:=i686-pc-cygwin-gcc-4

Now I have:

D:\Projects\dtc>make
CHK version_gen.h
CC srcpos.o
CC util.o
cc1: warnings being treated as errors
util.c: In function `util_is_printable_string’:
util.c:90:3: error: array subscript has type `char’
make: *** [util.o] Error 1

This is because the -Werror flag in the make file, remove it and I have:

D:\Projects\dtc>dir *.exe
Volume in drive D is Data
Volume Serial Number is EFCE-4830

Directory of D:\Projects\dtc

08/15/2017 03:50 PM 115,009 convert-dtsv0.exe
08/15/2017 03:50 PM 279,645 dtc.exe
08/15/2017 03:50 PM 78,242 fdtdump.exe
08/15/2017 03:50 PM 106,605 fdtget.exe
08/15/2017 03:50 PM 134,453 fdtput.exe

Let’s use it:

D:\Projects\AndromaxQ\carliv\boot>dtc -I dtb -O dts -o mydts.dts boot.img-dt
FATAL ERROR: Blob has incorrect magic number

Seems, that this file is not intended to be processed by dtc.

Obtain dtbTool from github and compile:

D:\Projects\dtbTool>make
i686-pc-cygwin-gcc-4 -O2 -g -Wall -c dtbtool.c
dtbtool.c: In function `getChipInfo’:
dtbtool.c:273:23: warning: `entryEndedST’ may be used uninitialized in this func
tion
dtbtool.c:273:51: warning: `entryEndedDT’ may be used uninitialized in this func
tion
dtbtool.c:273:79: warning: `entryEndedPT’ may be used uninitialized in this func
tion
i686-pc-cygwin-gcc-4 -g -o dtbtool dtbtool.o

But actually the dtbTools is used to create the dt.img from files of *.dtb.

But now let’s use this:

D:\Projects\dtbTool>gcc split-appended-dtb.c -o split-appended-dtb

Now executed it at:

D:\Projects\AndromaxQ\carliv\boot>split-appended-dtb boot.img-dt
Found 47 appended dtbs, please check the output.

D:\Projects\AndromaxQ\carliv\boot>dir *.dtb
Volume in drive D is Data
Volume Serial Number is EFCE-4830

Directory of D:\Projects\AndromaxQ\carliv\boot

08/15/2017 04:40 PM 178,176 dtbdump_1.dtb
08/15/2017 04:40 PM 163,840 dtbdump_10.dtb
08/15/2017 04:40 PM 163,840 dtbdump_11.dtb

Let’s try our dtc.exe again:

D:\Projects\AndromaxQ\carliv\boot>dtc -I dtb -O dts -o mydts.dts dtbdump_1.dtb

It runs without error this time. And I have a decompiled *.dts file here:

How the BBM Android Application Get the Incoming Message

June 30, 2017

The routine to process incoming and outgoing message resides in BbmCoreService.java. This is after the libbbmcore.so library is loaded and proper authentication process is done successfully.

After libbbmcore.so is loaded and functional, periodically it will call a method in BbmCoreService class called prv_msgFromService. This is the incoming messages, which has many types, including advertising messages. This in turn will call the callback and other necessary routines, such as notifications, etc.

Likewise, the outgoing message is constructed to suitable format before sending it via the native method called prv_msgToService, also in libbbmcore.so.

Hope this small burst of information can help πŸ™‚

After more detailed examination, I can added that the routine to handle incoming message resides in libtransport.so native library. It is implemented using socket, connect, select and recv socket functions.

On the start up of this library (i.e. the libtransport.so), it tries to connect to one of the BBM server IP Addresses, which is from 74.82.64.0 to 74.82.95.255, using SOCK_DGRAM connection type.

The received data is in encrypted form, and it is decrypted locally using SSL_read combined with BIO_write function, after properly set up the link between BIO and SSL functions using SSL_set_bio.

After the received data is processed, the libtransport.so routine will perform write to the created write end point of the pipe from libbbmcore.so routines. This will trigger the necessary functions such as showing the Notification with is BBM tone, etc.

How to Compile Android Lollipop (5.1.1) Contacts onWindows OS

June 21, 2017

This is the modified build system to be used to compile existing APK from Android Lollipop 5.1.1 Framework. In this example it is used to compile Android’s Contacts.apk.

You can used it also to compile another Android packages.

The build system is taken from android-5.1.1_r38 source tree. Basically the compile error is not finding which module that is required, the slash or backslash problem and certain script code that is not supported by bash shell on Windows OS.

There’s also the problem when unzipping the download *.gz file from Android source repository. You should use the gzip and tar command line program from MSYS or GNUWIN32.

The build script is proven to be successfully run on windows version 7-6.1.7601-SP1.

The modified build scripts already uploaded to github:

https://github.com/surya-rakanta/AndroidBuildSystemOnWindows

Below is the log of compiling session from start to finish and how to solve each compiling issue one by one.

The script is checked and revised using the probe text such as until …, etc, so you will see some weird output such as until herexxy9aay2, etc, in the compiling session log below. Ignore it.

You can examine the final modified build system in the downloaded from github.

Retrieve the source from:

https://android.googlesource.com/platform/packages/apps/Contacts/+/android-5.1.1_r38

Put it into structures here:

D:\Projects\Lollipop\platform\packages\apps\Contacts

Download build system:

https://android.googlesource.com/platform/build/+/android-5.1.1_r38

Put it here:

D:\Projects\Lollipop\platform\build

Perform modification in envsetup.sh, but first copy this shell file into back up file

Execute envsetup.sh, and we have:

D:\Projects\Lollipop\platform\build>bash
bash-3.1$ ./envsetup.sh
./envsetup.sh: line 1134: unexpected argument `(‘ to conditional binary operator

./envsetup.sh: line 1134: syntax error near `(^’
./envsetup.sh: line 1134: ` if [[ $CPU_ABI =~ (^|,)arm64 ]]; then’

Remark it

We have:

bash-3.1$ ./envsetup.sh
./envsetup.sh: line 1184: unexpected argument `(‘ to conditional binary operator

./envsetup.sh: line 1184: syntax error near `(^’
./envsetup.sh: line 1184: ` if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$
]]; then’

Remark again:

We have:

bash-3.1$ ./envsetup.sh
./envsetup.sh: line 1279: unexpected argument `(‘ to conditional binary operator

./envsetup.sh: line 1279: syntax error near `(^’
./envsetup.sh: line 1279: ` if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|
64)$ ]]; then’

Remark

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/envsetup.mk:67: *** Unable to determine HOST_OS from uname -sm: MINGW
32_NT-6.1 i686!. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets ####

Modify in D:\Projects\Lollipop\platform\build\core\envsetup.mk:

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/envsetup.mk:94: *** Unable to determine HOST_ARCH from uname -sm: MIN
GW32_NT-6.1 i686!. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets ####

Modify in D:\Projects\Lollipop\platform\build\core\envsetup.mk:

HOST_ARCH := x86

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/config.mk:454: *** Error: could not find jdk tools.jar, please check
if your JDK was installed correctly. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (1 seconds) ####

Checking:

D:\Projects\Lollipop\platform>bash
bash-3.1$ build/core/find-jdk-tools-jar.sh
/c/Program Files (x86)/Java/jdk1.6.0_26/lib/tools.jar

Remark in D:\Projects\Lollipop\platform\build\core\config.mk:

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
Checking build tools versions…
************************************************************
You are attempting to build with the incorrect version
of java.

Your version is: java version “1.8.0_131” Java(TM) SE Runtime Environment (build
1.8.0_131-b11) Java HotSpot(TM) Client VM (build 25.131-b11, mixed mode, sharin
g).
The required version is: “1.7.x”

Please follow the machine setup instructions at
https://source.android.com/source/initializing.html
************************************************************
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/main.mk:167: *** stop. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (6 seconds) ####

bash-3.1$

Install jdk-7u79-windows-i586.exe, change windows path environment and verify:

C:\Windows\System32>java -version
java version “1.7.0_79”
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode, sharing)

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
Checking build tools versions…
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/main.mk:459: sdk/build/windows_sdk_whitelist.mk: No such file or dire
ctory
build/core/main.mk:460: development/build/windows_sdk_whitelist.mk: No such file
or directory
including build/tools/acp\Android.mk …

#### make failed to build some targets (32 seconds) ####

bash-3.1$

And the windows crash:

The cause of this crash is located at D:\Projects\Lollipop\platform\build\core\base_rules.mk:

gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)

Create a test make file called mktest.mk inside D:\Projects\Lollipop\platform with content as follows:

#SHELL := /bin/bash

###########################################################
## Scan through each directory of $(1) looking for files
## that match $(2) using $(wildcard). Useful for seeing if
## a given directory or one of its parents contains
## a particular file. Returns the first match found,
## starting furthest from the root.
###########################################################
$(info until herexxy9aa1)

define find-parent-file
$(strip \
$(eval _fpf := $(wildcard $(foreach f, $(2), $(strip $(1))/$(f)))) \
$(if $(_fpf),$(_fpf), \
$(if $(filter-out ./ .,$(1)), \
$(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
) \
) \
)
endef

LOCAL_PATH := “build/tools/acp\”
$(info until $(LOCAL_PATH))

gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)

The cause of make program crash is present of unwanted backslash in build/tools/acp\

Remark by making gpl_license_file blank for the moment, we have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/main.mk:459: sdk/build/windows_sdk_whitelist.mk: No such file or dire
ctory
build/core/main.mk:460: development/build/windows_sdk_whitelist.mk: No such file
or directory
including build/tools/acp\Android.mk …
until herexxy9aay2
make: *** No rule to make target `development/build/windows_sdk_whitelist.mk’.
Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (13 seconds) ####

Retrieve sdk tree.

Place it in in local directory

Retrieve development tree from:

Place it in:

Change envsetup.sh script inside function make():

local start_time=$(date +”%s”)
#$(get_make_command) “$@”
command make -C /d/Projects/Lollipop/platform -f build/core/main.mk BUILD_MODULES_IN_PATHS=d:/Projects/Lollipop/platform/packages/apps/Contacts -p > myMake1.txt

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
/bin/bash: line 0: cd: development/appsBluetoothDebug : No such file or director
y
/bin/bash: line 0: cd: development/appsBuildWidget : No such file or directory
find: src: No such file or directory
build/core/java.mk:23: *** development/apps\BuildWidget\: Invalid LOCAL_SDK_VERS
ION ‘current’ Choices are: . Stop.

#### make failed to build some targets (11 seconds) ####

Checking the included sub directories in D:\Projects\Lollipop\platform\build\core\main.mk using info statement:

D:\Projects\Lollipop\platform\build\core\main.mk

We get the result:

the sub dirs external/openssl prebuilt prebuilts build/libs/host build/tools/z
ipalign dalvik/dexdump dalvik/libdex dalvik/tools/dmtracedump dalvik/tools/hprof
-conv development/host development/tools/etc1tool development/tools/line_endings
external/clang external/easymock external/expat external/gtest external/libcxx
external/libcxxabi external/compiler-rt external/libpng external/llvm external/s
qlite/dist external/zlib external/zopfli frameworks/base frameworks/compile fram
eworks/native frameworks/rs frameworks/tools system/core/adb system/core/fastboo
t system/core/libcutils system/core/liblog system/core/libsparse system/core/lib
ziparchive system/core/libzipfile system/core/libutils system/extras/ext4_utils
build/tools/signapk dalvik/dx libcore development/apps development/tools/mkstubs
frameworks/compile/libbcc packages build/tools/acp

Probing with:

$(info the sub dir make file $(subdir_makefiles))

We get:

the sub dir make file build/libs/host\Android.mk build/tools/acp\Android.mk buil
d/tools/signapk\Android.mk build/tools/zipalign\Android.mk development/apps\Blue
toothDebug\Android.mk development/apps\BuildWidget\Android.mk development/apps\C
ustomLocale\Android.mk development/apps\DevelopmentSettings\Android.mk developme
nt/apps\Development\Android.mk development/apps\Fallback\Android.mk development/
apps\GestureBuilder\Android.mk development/apps\NinePatchLab\Android.mk developm
ent/apps\OBJViewer\Android.mk development/apps\SdkSetup\Android.mk development/a
pps\SettingInjectorSample\Android.mk development/apps\WidgetPreview\Android.mk d
evelopment/apps\launchperf\Android.mk development/host\Android.mk development/to
ols/etc1tool\Android.mk development/tools/line_endings\Android.mk development/to
ols/mkstubs\Android.mk packages\apps\ContactsCommon\Android.mk packages\apps\Con
tacts\Android.mk

Most of the program is not needed, so just re-assign the subdir_makefiles in D:\Projects\Lollipop\platform\build\core\main.mk:

subdir_makefiles := packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk

Now we have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
including packages/apps/ContactsCommon/Android.mk …
find: ../PhoneCommon/src: No such file or directory
including packages/apps/Contacts/Android.mk …
find: ../PhoneCommon/src: No such file or directory
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `prebuilts/sdk/api/.txt’, needed by `out/target
/common/obj/PACKAGING/checkpublicapi-last-timestamp’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (14 seconds) ####

bash-3.1$

Retrieve PhoneCommon source tree from:

Place it in:

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `prebuilts/sdk/api/.txt’, needed by `out/target
/common/obj/PACKAGING/checkpublicapi-last-timestamp’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (15 seconds) ####

bash-3.1$

Copy files from:

Place it in:

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
make: *** No rule to make target `out/target/common/obj/PACKAGING/public_api.txt
‘, needed by `out/target/common/obj/PACKAGING/checkpublicapi-last-timestamp’. S
top.

#### make failed to build some targets (14 seconds) ####

out/target/common/obj/PACKAGING/checkpublicapi-last-timestamp: prebuilts/sdk/api/22.txt out/target/common/obj/PACKAGING/public_api.txt frameworks/base/api/removed.txt out/host/windows-x86/bin/apicheck.exe out/target/common/docs/api-stubs-timestamp
# Implicit rule search has not been done.
# File does not exist.
# File has not been updated.
# variable set hash-table stats:
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
# commands to execute (from `build/core/tasks/apicheck.mk’, line 46):
@echo “Checking API:” checkpublicapi-last
@ ( out/host/windows-x86/bin/apicheck.exe -JXmx1024m -J”classpath /c/Program Files (x86)/Java/jdk1.7.0_79/lib/tools.jar:out/host/windows-x86/framework/doclava.jar:out/host/windows-x86/framework/jsilver.jar” -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 -error 16 -error 17 -error 18 prebuilts/sdk/api/22.txt out/target/common/obj/PACKAGING/public_api.txt frameworks/base/api/removed.txt out/target/common/obj/PACKAGING/removed.txt || ( cat build/core/apicheck_msg_last.txt ; exit 38 ) )
@ mkdir -p $(dir $@)
@ touch $@

# INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
# Note that since INTERNAL_PLATFORM_API_FILE is the byproduct of api-stubs module,
# (See frameworks/base/Android.mk)
# we need to add api-stubs as additional dependency of the api check.

# Check that the API we’re building hasn’t broken the last-released
# SDK version.
$(eval $(call check-api, \
checkpublicapi-last, \
$(SRC_API_DIR)/$(last_released_sdk_version).txt, \
$(INTERNAL_PLATFORM_API_FILE), \
frameworks/base/api/removed.txt, \
$(INTERNAL_PLATFORM_REMOVED_API_FILE), \
-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
-error 16 -error 17 -error 18 , \
cat $(BUILD_SYSTEM)/apicheck_msg_last.txt, \
check-public-api, \
$(call doc-timestamp-for,api-stubs) \
))

The out/target/common/obj/PACKAGING/public_api.txt is generated by the command:

update-public-api: out/target/common/obj/PACKAGING/public_api.txt | out/host/-x86/bin/acp
# Phony target (prerequisite of .PHONY).
# Implicit rule search has not been done.
# File does not exist.
# File has not been updated.
# commands to execute (from `build/core/tasks/apicheck.mk’, line 79):
@echo Copying current.txt
$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) frameworks/base/api/current.txt
@echo Copying removed.txt
$(hide) $(ACP) $(INTERNAL_PLATFORM_REMOVED_API_FILE) frameworks/base/api/removed.txt

Retrieve source tree from:

Place it in:

But we still have:

make: *** No rule to make target `out/target/common/obj/PACKAGING/public_api.txt
‘, needed by `out/target/common/obj/PACKAGING/checkpublicapi-last-timestamp’. S
top.

Let’s try to build ACP first, but we have:

# ACP is always for the build OS, not for the host OS
ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX)

BUILD_OUT_EXECUTABLES := out/host/-x86/bin

Which is:

BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin

Where as:

BUILD_OUT := $(OUT_DIR)/host/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)

Modify in D:\Projects\Lollipop\platform\build\core\envsetup.mk:

Let’s revert to original one:

command make -C /d/Projects/Lollipop/platform -f build/core/main.mk all_modules BUILD_MODULES_IN_PATHS= build/d:/Projects/Lollipop/platform/packages/apps/Contacts -p > myMake2.txt

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
including build/libs/host\Android.mk …
including build/tools/acp\Android.mk …
including build/tools/signapk\Android.mk …
including build/tools/zipalign\Android.mk …
including development/apps\BluetoothDebug\Android.mk …
/bin/bash: line 0: cd: development/appsBluetoothDebug : No such file or director
y
including development/apps\BuildWidget\Android.mk …
/bin/bash: line 0: cd: development/appsBuildWidget : No such file or directory
find: src: No such file or directory
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:23: *** development/apps\BuildWidget\: Invalid LOCAL_SDK_VERS
ION ‘current’ Choices are: . Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (11 seconds) ####

bash-3.1$

Check environment variables:

Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS))

# makefile (from `build/core/config.mk’, line 599)
TARGET_AVAILABLE_SDK_VERSIONS :=

TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\
$(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
$(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))

HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk

Download from:

Place it in:

We have:

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
including build/libs/host\Android.mk …
including build/tools/acp\Android.mk …
including build/tools/signapk\Android.mk …
including build/tools/zipalign\Android.mk …
including development/apps\BluetoothDebug\Android.mk …
/bin/bash: line 0: cd: development/appsBluetoothDebug : No such file or director
y
including development/apps\BuildWidget\Android.mk …
/bin/bash: line 0: cd: development/appsBuildWidget : No such file or directory
find: src: No such file or directory
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:23: *** development/apps\BuildWidget\: Invalid LOCAL_SDK_VERS
ION ‘current’ Choices are: 21. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (11 seconds) ####

bash-3.1$

Edit the subdir_makefiles to:

subdir_makefiles := build/libs/host\Android.mk build/tools/acp\Android.mk build/tools/signapk\Android.mk build/tools/zipalign\Android.mk development/apps/BluetoothDebug\Android.mk development/apps/BuildWidget\Android.mk development/apps/CustomLocale\Android.mk development/apps\DevelopmentSettings\Android.mk development/apps/Development\Android.mk development/apps/Fallback\Android.mk development/apps/GestureBuilder\Android.mk development/apps/NinePatchLab\Android.mk development/apps/OBJViewer\Android.mk development/apps/SdkSetup\Android.mk development/apps/SettingInjectorSample\Android.mk development/apps/WidgetPreview\Android.mk development/apps/launchperf\Android.mk development/host\Android.mk development/tools/etc1tool\Android.mk development/tools/line_endings\Android.mk development/tools/mkstubs\Android.mk packages/apps/ContactsCommon\Android.mk packages/apps/Contacts\Android.mk

And change the command inside function make():

command make -C /d/Projects/Lollipop/platform -f build/core/main.mk all_modules BUILD_MODULES_IN_PATHS= d:/Projects/Lollipop/platform/packages/apps/Contacts

bash-3.1$ ./envsetup.sh
ps: illegal option — o
Usage ps [-aefl] [-u uid]
-f = show process uids, ppids
-l = show process uids, ppids, pgids, winpids
-u uid = list processes owned by uid
-a, -e = show processes of all users
-s = show process summary
-W = show windows as well as cygwin processes
WARNING: Only bash is supported, use of other shell would lead to erroneous resu
lts
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86
HOST_OS=windows
HOST_OS_EXTRA=Windows-7-6.1.7601-SP1
HOST_BUILD_TYPE=release
BUILD_ID=LMY49M
OUT_DIR=out
============================================
including build/libs/host\Android.mk …
including build/tools/acp\Android.mk …
including build/tools/signapk\Android.mk …
including build/tools/zipalign\Android.mk …
including development/apps/BluetoothDebug\Android.mk …
including development/apps/BuildWidget\Android.mk …
including development/apps/CustomLocale\Android.mk …
including development/apps\DevelopmentSettings\Android.mk …
including development/apps/Development\Android.mk …
including development/apps/Fallback\Android.mk …
including development/apps/GestureBuilder\Android.mk …
including development/apps/NinePatchLab\Android.mk …
including development/apps/OBJViewer\Android.mk …
including development/apps/SdkSetup\Android.mk …
including development/apps/SettingInjectorSample\Android.mk …
including development/apps/WidgetPreview\Android.mk …
including development/apps/launchperf\Android.mk …
including development/host\Android.mk …
including development/tools/etc1tool\Android.mk …
including development/tools/line_endings\Android.mk …
including development/tools/mkstubs\Android.mk …
including packages/apps/ContactsCommon\Android.mk …
including packages/apps/Contacts\Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
Import includes file: out/host/windows-x86/obj/STATIC_LIBRARIES/libhost_intermed
iates/import_includes
host C: libhost <= build/libs/host\/CopyFile.c
build/libs/host/CopyFile.c:1:0: warning: -fPIC ignored for target (all code is p
osition independent) [enabled by default]
gcc.exe: warning: out/host/windows-x86/obj/STATIC_LIBRARIES/libhost_intermediate
s: linker input file unused because linking not done
Export includes file: build/libs/hostAndroid.mk — out/host/windows-x86/obj/STAT
IC_LIBRARIES/libhost_intermediates/export_includes
host StaticLib: libhost (out/host/windows-x86/obj/STATIC_LIBRARIES/libhost_inter
mediates/libhost.a)
Import includes file: out/host/windows-x86/obj/EXECUTABLES/acp_intermediates/imp
ort_includes
host C: acp /dev/null))
subdirs += \
# external/ant-glob \
# external/eclipse-windowbuilder/propertysheet \
# external/hamcrest \
# external/junit \
# sdk/apkbuilder \
# sdk/eclipse/scripts/rcp \
# sdk/testutils

subdirs += \
prebuilt \
prebuilts \
build/libs/host \
build/tools/zipalign \
dalvik/dexdump \
dalvik/libdex \
dalvik/tools/dmtracedump \
dalvik/tools/hprof-conv \
development/host \
development/tools/etc1tool \
development/tools/line_endings \
external/clang \
external/easymock \
external/expat \
external/gtest \
external/libcxx \
external/libcxxabi \
external/compiler-rt \
external/libpng \
external/llvm \
external/sqlite/dist \
external/zlib \
external/zopfli \
frameworks/base \
frameworks/compile \
frameworks/native \
frameworks/rs \
frameworks/tools \
system/core/adb \
system/core/fastboot \
system/core/libcutils \
system/core/liblog \
system/core/libsparse \
system/core/libziparchive \
system/core/libzipfile \
system/core/libutils \
system/extras/ext4_utils

subdirs += \
build/tools/signapk \
dalvik/dx \
libcore \
development/apps \
development/tools/mkstubs \
frameworks/compile/libbcc \
packages

Building Contacts.apk:

command make -C /d/Projects/Lollipop/platform -f build/core/main.mk out/target/product/generic/obj/APPS/Contacts_intermediates/package.apk

out/target/product/generic/system/priv-app/Contacts/Contacts.apk: out/target/product/generic/obj/APPS/Contacts_intermediates/package.apk | out/host/windows-x86/bin/acp out/target/product/generic/obj/NOTICE_FILES/src//system/priv-app/Contacts/Contacts.apk.txt

make: *** No rule to make target `out/host/windows-x86/bin/aapt.exe’, needed by
`out/target/common/obj/APPS/Contacts_intermediates/src/R.stamp’. Stop.
./envsetup.sh: line 1704: out/target/product/generic/obj/APPS/Contacts_intermedi
ates/package.apk: No such file or directory

Copy existing aapt.exe from latest Android tools sdk to the directory.

We have:

make: Entering directory `/d/Projects/Lollipop/platform’
target R.java/Manifest.java: Contacts (out/target/common/obj/APPS/Contacts_inter
mediates/src/R.stamp)
ERROR: resource directory ‘frameworks\support\v7\cardview\res’ does not exist
make: *** [out/target/common/obj/APPS/Contacts_intermediates/src/R.stamp] Error
1
make: Leaving directory `/d/Projects/Lollipop/platform’
./envsetup.sh: line 1704: out/target/product/generic/obj/APPS/Contacts_intermedi
ates/package.apk: No such file or directory

#### make failed to build some targets (17 seconds) ####

Copy from:

We have:

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/sdk_v21_i
ntermediates/classes.jar’, needed by `out/target/common/obj/APPS/Contacts_interm
ediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’
./envsetup.sh: line 1704: out/target/product/generic/obj/APPS/Contacts_intermedi
ates/package.apk: No such file or directory

full_java_lib_deps := out/target/common/obj/JAVA_LIBRARIES/android.test.runner_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/com.android.contacts.common.test_intermediates/javalib.jar out/target/common/obj/APPS/Contacts_intermediates/classes.jar

including build/libs/host\Android.mk …
the full java libx
including build/tools/acp\Android.mk …
the full java libx
including build/tools/signapk\Android.mk …
the full java libx
including build/tools/zipalign\Android.mk …
the full java libx out/host/common/obj/JAVA_LIBRARIES/bouncycastle-host_interm
ediates/javalib.jar out/host/common/obj/JAVA_LIBRARIES/bouncycastle-bcpkix-host
_intermediates/javalib.jar
including development/apps/BluetoothDebug\Android.mk …
the full java libx out/host/common/obj/JAVA_LIBRARIES/bouncycastle-host_interm
ediates/javalib.jar out/host/common/obj/JAVA_LIBRARIES/bouncycastle-bcpkix-host
_intermediates/javalib.jar
including development/apps/BuildWidget\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/CustomLocale\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps\DevelopmentSettings\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/Development\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/Fallback\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/android.test.runner_inte
rmediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates
/classes.jar out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates
/classes.jar
including development/apps/GestureBuilder\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/NinePatchLab\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/OBJViewer\Android.mk …
including development/apps/SdkSetup\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/SettingInjectorSample\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/WidgetPreview\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/apps/launchperf\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar
including development/host\Android.mk …
including development/tools/etc1tool\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/android.test.runner_inte
rmediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates
/classes.jar
including development/tools/line_endings\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/android.test.runner_inte
rmediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates
/classes.jar
including development/tools/mkstubs\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/android.test.runner_inte
rmediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates
/classes.jar
including packages/apps/ContactsCommon\Android.mk …
the full java libx out/host/common/obj/JAVA_LIBRARIES/asm-4.0_intermediates/ja
valib.jar
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/
javalib.jar out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.ja
r out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib
.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/java
lib.jar out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javal
ib.jar out/target/common/obj/JAVA_LIBRARIES/libgeocoding_intermediates/javalib.
jar
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/
javalib.jar out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.ja
r out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib
.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/java
lib.jar out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javal
ib.jar out/target/common/obj/JAVA_LIBRARIES/libgeocoding_intermediates/javalib.
jar
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/
javalib.jar out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.ja
r out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib
.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/java
lib.jar out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javal
ib.jar out/target/common/obj/JAVA_LIBRARIES/libgeocoding_intermediates/javalib.
jar
the full java libx out/target/common/obj/JAVA_LIBRARIES/android.test.runner_inte
rmediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/c
lasses.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/classes.ja
r out/target/common/obj/APPS/com.android.contacts.common_intermediates/classes
.jar
including packages/apps/Contacts\Android.mk …
the full java libx out/target/common/obj/JAVA_LIBRARIES/android.test.runner_inte
rmediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates
/classes.jar out/target/common/obj/JAVA_LIBRARIES/com.android.contacts.common.t
est_intermediates/javalib.jar out/target/common/obj/APPS/com.android.contacts.c
ommon_intermediates/classes.jar
the full java libx out/target/common/obj/JAVA_LIBRARIES/sdk_v21_intermediates/cl
asses.jar out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/cl
asses.jar out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes
.jar out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/javal
ib.jar out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javali
b.jar out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.jar out
/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v7-cardview_intermediates/
javalib.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v7-palette_int
ermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v4_
intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/libphonenumber_i
ntermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/libgeocoding_inte
rmediates/javalib.jar
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/sdk_v21_i
ntermediates/classes.jar’, needed by `out/target/common/obj/APPS/Contacts_interm
ediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’
./envsetup.sh: line 1704: out/target/product/generic/obj/APPS/Contacts_intermedi
ates/package.apk: No such file or directory

#### make failed to build some targets (17 seconds) ####

bash-3.1$

The sdk_v21 is the result of:

$(LOCAL_JAVA_LIBRARIES)

Which is from D:\Projects\Lollipop\platform\build\core\java.mk:

LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)

Try copy Android.mk and CleanSpec.mk from:

To:

markerxy core-libart conscrypt okhttp core-junit bouncycastle ext

We have:

============================================
including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
including prebuilts/sdk/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/APPS/framework-res_inter
mediates/src/R.stamp’, needed by `out/target/common/obj/APPS/Contacts_intermedia
tes/src/R.stamp’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (30 seconds) ####

# makefile (from `build/core/package_internal.mk’, line 303)
framework_res_package_export_deps := out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp

Perform some changes inside D:\Projects\Lollipop\platform\build\core\package_internal.mk:

useful command:

$(info the localsdkresy $(LOCAL_SDK_RES_VERSION))

Now we have:

including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
including prebuilts/sdk/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/core-juni
t_intermediates/classes.jar’, needed by `out/target/common/obj/APPS/com.android.
contacts.common_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

out/target/common/obj/APPS/com.android.contacts.common_intermediates/classes-full-debug.jar: out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/libgeocoding_intermediates/javalib.jar out/target/common/obj/APPS/com.android.contacts.common_intermediates/src/R.stamp

Copy the required junit from platform/external/junit:

We have:

including external/junit/Android.mk …
the full java libx2 out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_inter
mediates/javalib.jar
the full java libx2 out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_inter
mediates/javalib.jar
the full java libx2 out/host/common/obj/JAVA_LIBRARIES/core-junit-hostdex_interm
ediates/javalib.jar out/host/common/obj/JAVA_LIBRARIES/core-libart-hostdex_inter
mediates/javalib.jar
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:23: *** external/junit: Invalid LOCAL_SDK_VERSION ‘4’ Choices
are: current 21. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (7 seconds) ####

Download version of 4 of local sdk, we have:

make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/core-liba
rt_intermediates/classes.jar’, needed by `out/target/common/obj/JAVA_LIBRARIES/c
ore-junit_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Copy from:

We have:

including prebuilts/sdk/Android.mk …
make: *** No rule to make target `external/stlport/libstlport.mk’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

copy from:

https://android.googlesource.com/platform/external/stlport/+/android-5.1.1_r38

We have:

target Java: core-libart (out/target/common/obj/JAVA_LIBRARIES/core-libart_inter
mediates/classes)
cygwin warning:
MS-DOS style path detected: d:/Projects/Lollipop/platform
Preferred POSIX equivalent is: /cygdrive/d/Projects/Lollipop/platform
CYGWIN environment variable option “nodosfilewarning” turns off this warning.
Consult the user’s guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
sh: /cygdrive/c/Program Files (x86)/Java/jdk1.7.0_79/bin/javac: Argument list to
o long

Checking:

# makefile (from `build/core/definitions.mk’, line 1617)
define transform-java-to-classes.jar
@echo “target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))”
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH))
endef

target Java: core-libart (out/target/common/obj/JAVA_LIBRARIES/core-libart_inter
mediates/classes Compile with development/host/windows/prebuilt/javawrap.exe -J-
Xmx256m -source 1.7 -target 1.7 -Xmaxerrs 9999999 and parameter -bootclasspath o
ut/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar)
cygwin warning:

From command line we have:

D:\Projects\Lollipop\platform>bash
bash-3.1$ d:/Projects/Lollipop/platform/development/host/windows/prebuilt/javaw
rap.exe -J-Xmx256m -source 1.7 -target 1.7 -Xmaxerrs 9999999 -encoding UTF-8 -g
-bootclasspath out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/
classes.jar -extdirs “””” -d out/target/common/obj/JAVA_LIBRARIES/core-libart_i
ntermediates/classes -encoding UTF-8 -Xmaxwarns 9999999 @out/target/common/obj/
JAVA_LIBRARIES/core-libart_intermediates/classes/java-source-list-uniq
cygwin warning:
MS-DOS style path detected: d:/Projects/Lollipop/platform
Preferred POSIX equivalent is: /cygdrive/d/Projects/Lollipop/platform
CYGWIN environment variable option “nodosfilewarning” turns off this warning.
Consult the user’s guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
sh: /cygdrive/c/Program Files (x86)/Java/jdk1.7.0_79/bin/javac: Argument list to
o long

Uses javac.exe:

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/ext_inter
mediates/classes.jar’, needed by `out/target/common/obj/APPS/Contacts_intermedia
tes/classes-full-debug.jar’. Stop.

Problem starts at:

out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar: out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/emma_out/lib/classes-jarjar.jar | out/host/windows-x86/bin/acp

out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/emma_out/lib/classes-jarjar.jar: out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes-jarjar.jar | out/host/windows-x86/bin/acp

out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes-jarjar.jar: out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes-full-debug.jar | out/host/windows-x86/bin/acp

out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes-full-debug.jar: …

is generated via:

# commands to execute (from `build/core/java.mk’, line 345):
$(transform-java-to-classes.jar)

Where the classes.jar is malformed

But eventually changes inside D:\Projects\Lollipop\platform\build\core\definitions.mk:

Makes it work !

Remove the modifications LOCAL_SDK_RES_VERSION on D:\Projects\Lollipop\platform\build\core\package_internal.mk. And compile using:

subdir_makefiles := libcore/Android.mk external/junit/Android.mk frameworks/base/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

But we have:

/bin/bash: line 0: cd: frameworks/base/../../external/libphonenumber/java/src: N
o such file or directory
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:267: *** frameworks/base: Target java module does not define
any source or resource files. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Which cause by this logic in D:\Projects\Lollipop\platform\build\core\java.mk:

Causes by blank in:

need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))

all_java_sources := $(subst ,, )

But let’s see if we try to resolve the find errors as in:

find: phone/java: No such file or directory
find: ../../external/apache-http/src/org/apache/http: No such file or directory
find: ../opt/telephony/src/java/android/provider: No such file or directory
find: ../opt/telephony/src/java/android/telephony: No such file or directory
find: ../opt/telephony/src/java/android/telephony/gsm: No such file or directory

find: ../opt/net/voip/src/java/android/net/rtp: No such file or directory
find: ../opt/net/voip/src/java/android/net/sip: No such file or directory
find: ../../external/apache-http/src/org/apache/http: No such file or directory
find: ../opt/telephony/src/java/android/provider: No such file or directory
find: ../opt/telephony/src/java/android/telephony: No such file or directory
find: ../opt/telephony/src/java/android/telephony/gsm: No such file or directory

find: ../opt/net/voip/src/java/android/net/rtp: No such file or directory
find: ../opt/net/voip/src/java/android/net/sip: No such file or directory
find: ../../frameworks/multidex/library/src: No such file or directory
find: ../../frameworks/multidex/instrumentation/src: No such file or directory
find: ../../external/apache-http/src/org/apache/http: No such file or directory
find: ../opt/telephony/src/java/android/provider: No such file or directory
find: ../opt/telephony/src/java/android/telephony: No such file or directory
find: ../opt/telephony/src/java/android/telephony/gsm: No such file or directory

find: ../opt/net/voip/src/java/android/net/rtp: No such file or directory
find: ../opt/net/voip/src/java/android/net/sip: No such file or directory
find: ../../external/nist-sip/java: No such file or directory
find: ../../external/apache-http/src: No such file or directory
find: ../../external/tagsoup/src: No such file or directory
find: ../../external/libphonenumber/java/src: No such file or directory
/bin/bash: line 0: cd: frameworks/base/../../external/libphonenumber/java/src: N
o such file or directory
the allx
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:267: *** frameworks/base: Target java module does not define
any source or resource files. Stop.

framework_docs_LOCAL_DROIDDOC_SOURCE_PATH := frameworks/base/core/java frameworks/base/graphics/java frameworks/base/location/java frameworks/base/media/java frameworks/base/media/mca/effect/java frameworks/base/media/mca/filterfw/java frameworks/base/media/mca/filterpacks/java frameworks/base/drm/java frameworks/base/opengl/java frameworks/base/sax/java frameworks/base/telecomm/java frameworks/base/telephony/java frameworks/base/phone/java frameworks/base/wifi/java frameworks/base/keystore/java frameworks/base/rs/java

FRAMEWORKS_BASE_SUBDIRS := core/java graphics/java location/java media/java media/mca/effect/java media/mca/filterfw/java media/mca/filterpacks/java drm/java opengl/java sax/java telecomm/java telephony/java phone/java wifi/java keystore/java rs/java

FRAMEWORKS_BASE_JAVA_SRC_DIRS := frameworks/base/core/java frameworks/base/graphics/java frameworks/base/location/java frameworks/base/media/java frameworks/base/media/mca/effect/java frameworks/base/media/mca/filterfw/java frameworks/base/media/mca/filterpacks/java frameworks/base/drm/java frameworks/base/opengl/java frameworks/base/sax/java frameworks/base/telecomm/java frameworks/base/telephony/java frameworks/base/phone/java frameworks/base/wifi/java frameworks/base/keystore/java frameworks/base/rs/java

Download from:

https://android.googlesource.com/platform/external/apache-http/+/android-5.1.1_r38

https://android.googlesource.com/platform/frameworks/opt/telephony/+/android-5.1.1_r38

https://android.googlesource.com/platform/frameworks/opt/net/voip/+/android-5.1.1_r38

https://android.googlesource.com/platform/frameworks/multidex/+/android-5.1.1_r38

https://android.googlesource.com/platform/external/nist-sip/+/android-5.1.1_r38

Now we have:

Clean step: rm -rf out/target/common/obj/JAVA_LIBRARIES/telephony-common_interme
diates
Clean step: rm -rf out/target/common/obj/JAVA_LIBRARIES/telephony-common_interme
diates
Clean step: rm -rf out/target/common/obj/JAVA_LIBRARIES/telephony-common_interme
diates
including frameworks/base/Android.mk …
find: ../../external/tagsoup/src: No such file or directory
find: ../../external/libphonenumber/java/src: No such file or directory
/bin/bash: line 0: cd: frameworks/base/../../external/libphonenumber/java/src: N
o such file or directory
including libcore/Android.mk …
including external/junit/Android.mk …
including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
including prebuilts/sdk/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/APPS/framework-res_inter
mediates/src/R.stamp’, needed by `out/target/common/obj/APPS/Contacts_intermedia
tes/src/R.stamp’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/external/tagsoup/+/android-5.1.1_r38

https://android.googlesource.com/platform/external/libphonenumber/+/android-5.1.1_r38

But this time we still have:

including frameworks/base/Android.mk …
including libcore/Android.mk …
including external/junit/Android.mk …
including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
including prebuilts/sdk/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/APPS/framework-res_inter
mediates/src/R.stamp’, needed by `out/target/common/obj/APPS/Contacts_intermedia
tes/src/R.stamp’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Checking:

out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp

# Not a target:
out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp:

# makefile (from `build/core/package_internal.mk’, line 305)
framework_res_package_export_deps := out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp

# makefile (from `frameworks/base/Android.mk’, line 415)
framework_res_R_stamp := out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp

# makefile (from `build/core/package_internal.mk’, line 313)
all_library_res_package_export_deps := out/target/common/obj/APPS/framework-res_intermediates/src/R.stamp

# makefile (from `frameworks/base/Android.mk’, line 27)
framework_res_source_path := APPS/framework-res_intermediates/src

curious one:
let’s check whether it is executed.

D:\Projects\Lollipop\platform\frameworks\base\core\res\Android.mk(20):LOCAL_PACKAGE_NAME := framework-res

Let’s dump again the subdirs this time:

the subdirsx build/libs/host\Android.mk build/tools/acp\Android.mk build/tools/s
ignapk\Android.mk build/tools/zipalign\Android.mk development/apps\BluetoothDebu
g\Android.mk development/apps\BuildWidget\Android.mk development/apps\CustomLoca
le\Android.mk development/apps\DevelopmentSettings\Android.mk development/apps\D
evelopment\Android.mk development/apps\Fallback\Android.mk development/apps\Gest
ureBuilder\Android.mk development/apps\NinePatchLab\Android.mk development/apps\
OBJViewer\Android.mk development/apps\SdkSetup\Android.mk development/apps\Setti
ngInjectorSample\Android.mk development/apps\WidgetPreview\Android.mk developmen
t/apps\launchperf\Android.mk development/host\Android.mk development/tools/etc1t
ool\Android.mk development/tools/line_endings\Android.mk development/tools/mkstu
bs\Android.mk frameworks/base\Android.mk libcore\Android.mk packages\apps\Contac
tsCommon\Android.mk packages\apps\Contacts\Android.mk packages\apps\PhoneCommon\
Android.mk prebuilts\sdk\Android.mk

Modify:

subdir_makefiles := frameworks/base/core/res/Android.mk frameworks/base/Android.mk libcore/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

Now we have:

including frameworks/base/core/res/Android.mk …
including frameworks/base/Android.mk …
including libcore/Android.mk …
including external/junit/Android.mk …
including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
including prebuilts/sdk/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
target Export Resources: framework-res (out/target/common/obj/APPS/framework-res
_intermediates/package-export.apk)
/bin/bash: zip: command not found
make: *** [out/target/common/obj/APPS/framework-res_intermediates/package-export
.apk] Error 127
make: *** Deleting file `out/target/common/obj/APPS/framework-res_intermediates/
package-export.apk’
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (39 seconds) ####

Checking:

# commands to execute (from `build/core/package_internal.mk’, line 265):
@echo “target Export Resources: $(PRIVATE_MODULE) ($@)”
$(create-empty-package)
$(add-assets-to-package)

Download zip.exe from gnuwin32.

There’s some long process of java compilation, and then we arrive at:

target Java: ext (out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes
Compile with development/host/windows/prebuilt/javawrap.exe -J-Xmx256m -source
1.7 -target 1.7 -Xmaxerrs 9999999 and parameter -bootclasspath out/target/common
/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar on out/target/common/o
bj/APPS/ContactsTests_intermediates/classes-full-debug.jar )
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Copying: out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes-jarjar.j
ar
Copying: out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/emma_out/lib/cla
sses-jarjar.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar
make: *** No rule to make target `out/host/windows-x86/bin/aidl.exe’, needed by
`out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/andr
oid/accessibilityservice/IAccessibilityServiceConnection.java’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

It’s easy, just copy the aidl.exe and it’s corresponding dlls from latest Android SDK’s build-tools to D:\Projects\Lollipop\platform\out\host\windows-x86\bin

Now we have:

logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/j
ava/android/content/EventLogTags.java <= frameworks/base/core/java/android/conte
nt/EventLogTags.logtags
logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/j
ava/android/speech/tts/EventLogTags.java <= frameworks/base/core/java/android/sp
eech/tts/EventLogTags.logtags
logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/j
ava/android/webkit/EventLogTags.java <= frameworks/base/core/java/android/webkit
/EventLogTags.logtags
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/bouncycas
tle_intermediates/classes.jar', needed by `out/target/common/obj/JAVA_LIBRARIES/
framework_intermediates/classes-full-debug.jar'. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform'

#### make failed to build some targets (1.:17. (mm:ss)) ####

Download from:

https://android.googlesource.com/platform/external/bouncycastle/+/android-5.1.1_r38

Revise:

subdir_makefiles := external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk libcore/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

Now we have:

============================================
including external/bouncycastle/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform'
build/core/java.mk:23: *** external/bouncycastle: Invalid LOCAL_SDK_VERSION '9'
Choices are: current 4 21. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform'

#### make failed to build some targets (8 seconds) ####

Just give it what it wants:

Download from:

https://android.googlesource.com/platform/prebuilts/sdk/+/android-5.1.1_r38/9/

We have:

make: Entering directory `/d/Projects/Lollipop/platform'
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/conscrypt
_intermediates/classes.jar', needed by `out/target/common/obj/JAVA_LIBRARIES/bou
ncycastle_intermediates/classes-full-debug.jar'. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform'

Download from:

https://android.googlesource.com/platform/external/conscrypt/+/android-5.1.1_r38

we have:

make: *** No rule to make target `out/host/windows-x86/framework/jarjar.jar', ne
eded by `out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-ja
rjar.jar'. Stop.

Checking:

out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar: out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-full-debug.jar external/conscrypt/jarjar-rules.txt | out/host/windows-x86/framework/jarjar.jar

# makefile (from `build/core/config.mk', line 406)
JARJAR := out/host/windows-x86/framework/jarjar.jar

Curious file in:

D:\Projects\Lollipop\platform\build\core\host_dalvik_java_library.mk(34):full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar

Modify subdir:

subdir_makefiles := build/core/host_dalvik_java_library.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk libcore/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

But we have:

including build/core/host_dalvik_java_library.mk …
make: Entering directory `/d/Projects/Lollipop/platform'
build/core/host_java_library_common.mk:42: *** : LOCAL_MODULE not defined before
call to local-intermediates-dir. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform'

revert subdir:

subdir_makefiles := build/core/host_dalvik_java_library.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk libcore/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

Modify subdir:

subdir_makefiles := libcore/Android.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk libcore/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

Download from:

https://android.googlesource.com/platform/external/jarjar/+/android-5.1.1_r38

Modify subdir:

subdir_makefiles := external/jarjar/Android.mk libcore/Android.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

But we have compile errors:

^
symbol: variable super
location: class KeepProcessor
100 errors
make: *** [out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/javalib.jar]
Error 41

Checking:

# commands to execute (from `build/core/host_java_library.mk', line 84):
$(transform-host-java-to-package)

define transform-host-java-to-package
@echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH))
$(if $(PRIVATE_EXTRA_JAR_ARGS), $(call add-java-resources-to-package))
endef

out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/javalib.jar: external/jarjar/src/main/com/tonicsystems/jarjar/AbstractDepHandler.java

This is caused by unzip not found. But still we have the error.

Extracting the javac command line using procmon.exe we have:

javac.exe -encoding UTF-8 -g -classpath out/host/windows-x86/framework/jarjar-apache-ant.jar:out/host/windows-x86/framework/jarjar-maven-plugin-api.jar:out/host/common/obj/JAVA_LIBRARIES/jarjar-asm_intermediates/javalib.jar:out/host/common/obj/JAVA_LIBRARIES/jarjar-asm-commons_intermediates/javalib.jar -extdirs """" -d out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/classes @out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/classes/java-source-list-uniq

After detail checking, it is caused by invalid separator for -classpath in windows environment that should use:

javac.exe -encoding UTF-8 -g -classpath out/host/windows-x86/framework/jarjar-apache-ant.jar;out/host/windows-x86/framework/jarjar-maven-plugin-api.jar;out/host/common/obj/JAVA_LIBRARIES/jarjar-asm_intermediates/javalib.jar;out/host/common/obj/JAVA_LIBRARIES/jarjar-asm-commons_intermediates/javalib.jar -extdirs "" -d out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/classes @out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/classes/java-source-list-uniq

Now we have:

host Java: jarjar (out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/class
es)
/bin/bash: -c: line 1: syntax error: unexpected end of file
make: *** [out/host/common/obj/JAVA_LIBRARIES/jarjar_intermediates/javalib.jar]
Error 2
make: Leaving directory `/d/Projects/Lollipop/platform'

Sample make command for testing:

define transform-host-java-to-packagex
$(hide) if [ -s myTest1.txt ] ; then \
javac -classpath out\a;out\b \
fi
endef

For semi colon problem:

define transform-host-java-to-packagex
$(hide) if [ -s myTest1.txt ] ; then \
javac -classpath out\a\;out\b; \
fi
endef

Original normalize-path:

###########################################################
## Convert "a b c" into "a:b:c"
###########################################################
define normalize-path-list
$(subst $(space),:,$(strip $(1)))
endef

This is caused by use of semi colon without escape character. The routine normalize-path-list should be:

###########################################################
## Convert "a b c" into "a:b:c"
#$(subst $(space),:,$(strip $(1)))
###########################################################
define normalize-path-list
$(subst $(space),\;,$(strip $(1)))
endef

But caution, because it will break in Linux environment.

Now. let's go !

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7 errors
make: *** [out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/class
es-full-debug.jar] Error 41
make: Leaving directory `/d/Projects/Lollipop/platform'

After performing some checking, it is found that the tgz file unzip using 7-zip is causing the truncated file names:

Using the tar command will alleviate the problem:

Report bugs to .

D:\temp>tar -xf test.tar

Now we have:

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/okhttp_in
termediates/classes.jar’, needed by `out/target/common/obj/JAVA_LIBRARIES/framew
ork_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/external/okhttp/+/android-5.1.1_r38

Now we have:

Copying: out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/emma_out/lib/
classes-jarjar.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar
make: *** No rule to make target `out/host/windows-x86/bin/rmtypedefs’, needed b
y `out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-deb
ug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Change the subdirs, now we have:

make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/host/common/obj/JAVA_LIBRARIES/asm-tools_i
ntermediates/javalib.jar’, needed by `out/host/common/obj/JAVA_LIBRARIES/rmtyped
efs_intermediates/javalib.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/prebuilts/tools/+/android-5.1.1_r38/common/

Then modify:

subdir_makefiles := prebuilts/tools/common/guava-tools/Android.mk prebuilts/tools/common/asm-tools/Android.mk development/tools/rmtypedefs/Android.mk external/okhttp/Android.mk external/jarjar/Android.mk libcore/Android.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

After a rather long compilation process, we have:

Deleting out\target\common\obj\JAVA_LIBRARIES\framework_intermediates\classes\an
droid\widget\NumberPicker$OnScrollListener$ScrollState.class
Deleting out\target\common\obj\JAVA_LIBRARIES\framework_intermediates\classes\an
droid\widget\Toast$Duration.class
Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-ja
rjar.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/emma_out/l
ib/classes-jarjar.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.ja
r
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/telephony
-common_intermediates/classes.jar’, needed by `out/target/common/obj/APPS/Contac
ts_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Compiled java program to be provided:

out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar
out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar
out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/guava_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v13_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v7-cardview_intermediates/javalib.jar out/target/common/obj/JAVA_LIBRARIES/android-support-v7-palette_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/libphonenumber_intermediates/javalib.jar
out/target/common/obj/JAVA_LIBRARIES/libgeocoding_intermediates/javalib.jar

Revise subdir:

subdir_makefiles := frameworks/opt/telephony/Android.mk prebuilts/tools/common/guava-tools/Android.mk prebuilts/tools/common/asm-tools/Android.mk development/tools/rmtypedefs/Android.mk external/okhttp/Android.mk external/jarjar/Android.mk libcore/Android.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

Download from:

https://android.googlesource.com/platform/frameworks/ex/+/android-5.1.1_r38

We have:

make: Entering directory `/d/Projects/Lollipop/platform’
Aidl: telephony-common <= frameworks/opt/telephony/src/java/com/android/internal
/telephony/IIccPhoneBook.aidl
logtags: out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/src
/src/java/com/android/internal/telephony/EventLogTags.java gzip -d test.tar.gz

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/android-c
ommon_intermediates/javalib.jar’, needed by `out/target/common/obj/APPS/Contacts
_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/frameworks/ex/+/android-5.1.1_r38

We have:

including frameworks/ex/common/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:23: *** frameworks/ex/common: Invalid LOCAL_SDK_VERSION ‘8’ C
hoices are: current 4 9 21. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/prebuilts/sdk/+/android-5.1.1_r38/8/

D:\Projects\Lollipop\platform\prebuilts\sdk\8>gzip -d test.tar.gz

D:\Projects\Lollipop\platform\prebuilts\sdk\8>tar -xf test.tar

After a long compilation process we have:

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/guava_int
ermediates/javalib.jar’, needed by `out/target/common/obj/APPS/Contacts_intermed
iates/classes-full-debug.jar’. Stop.

Download from:

https://android.googlesource.com/platform/external/guava/+/android-5.1.1_r38

https://android.googlesource.com/platform/frameworks/support/+/android-5.1.1_r38/v13

https://android.googlesource.com/platform/frameworks/support/+/android-5.1.1_r38/v7/

We have:

make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/jsr305_in
termediates/javalib.jar’, needed by `out/target/common/obj/JAVA_LIBRARIES/guava_
intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/external/jsr305/+/android-5.1.1_r38

We have:

============================================
including frameworks/support/v13/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
build/core/java.mk:23: *** frameworks/support/v13: Invalid LOCAL_SDK_VERSION ’14
‘ Choices are: current 4 8 9 21. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download:

https://android.googlesource.com/platform/prebuilts/sdk/+/android-5.1.1_r38/14/

Download all of those sdk number.

We have now:

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/android_s
tubs_current_intermediates/classes.jar’, needed by `out/target/common/obj/JAVA_L
IBRARIES/android-support-v4-api22_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download:

https://android.googlesource.com/platform/external/doclava/+/android-5.1.1_r38

make: Entering directory `/d/Projects/Lollipop/platform’
make: *** No rule to make target `out/host/windows-x86/framework/antlr-runtime.j
ar’, needed by `out/host/common/obj/JAVA_LIBRARIES/doclava_intermediates/javalib
.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

Download:

https://android.googlesource.com/platform/external/antlr/+/android-5.1.1_r38

https://android.googlesource.com/platform/external/jsilver/+/android-5.1.1_r38

make: *** No rule to make target `out/host/common/obj/JAVA_LIBRARIES/tagsouplib_
intermediates/javalib.jar’, needed by `out/host/common/obj/JAVA_LIBRARIES/doclav
a_intermediates/javalib.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

external\doclava\src\com\google\doclava\ClassInfo.java:20: error: package com.sun.javadoc does not exist
import com.sun.javadoc.ClassDoc;

This is caused by malformed path to the tools.jar in java path. The command line should be like this:

javac.exe -encoding UTF-8 -g -classpath out/host/windows-x86/framework/antlr-runtime.jar;out/host/windows-x86/framework/guavalib.jar;out/host/windows-x86/framework/jsilver.jar;out/host/common/obj/JAVA_LIBRARIES/tagsouplib_intermediates/javalib.jar;c:\Progra~2\Java\jdk1.7.0_80\lib\tools.jar -extdirs “” -d out/host/common/obj/JAVA_LIBRARIES/doclava_intermediates/classes @out/host/common/obj/JAVA_LIBRARIES/doclava_intermediates/classes/java-source-list-uniq

Perform revision in:

D:\Projects\Lollipop\platform\build\core\config.mk

HOST_JDK_TOOLS_JAR:= c:/Progra~2/Java/jdk1.7.0_80/lib/tools.jar

We have:

Install: out/host/windows-x86/framework/doclava.jar
Aidl Preprocess: out/target/common/obj/framework.aidl
Docs droiddoc: out/target/common/docs/api-stubs

After some long compilation process, we have:

Install: out/host/windows-x86/framework/doclava.jar
Aidl Preprocess: out/target/common/obj/framework.aidl
Docs droiddoc: out/target/common/docs/api-stubs
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: Leaving directory `/d/Projects/Lollipop/platform’

Change inD:\Projects\Lollipop\platform\build\core\droiddoc.mk:

-J-Xmx512m

We have:

make: Entering directory `/d/Projects/Lollipop/platform’
Docs droiddoc: out/target/common/docs/api-stubs
javadoc: error – Cannot find doclet class com.google.doclava.Doclava
1 error
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: Leaving directory `/d/Projects/Lollipop/platform’

This again, is caused by invalid separator as in:

javadoc.exe -encoding UTF-8 @out/target/common/obj/JAVA_LIBRARIES/api-stubs_intermediates/droiddoc-src-list -J-Xmx512m -XDignore.symbol.file -quiet -doclet com.google.doclava.Doclava -docletpath out/host/windows-x86/framework/jsilver.jar:out/host/windows-x86/framework/doclava.jar -templatedir build/tools/droiddoc/templates-sdk -htmldir frameworks/base/docs/html -bootclasspath out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar -classpath out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar: -sourcepath frameworks/base/core/java;frameworks/base/graphics/java;frameworks/base/location/java;frameworks/base/media/java;frameworks/base/media/mca/effect/java;frameworks/base/media/mca/filterfw/java;frameworks/base/media/mca/filterpacks/java;frameworks/base/drm/java;frameworks/base/opengl/java;frameworks/base/sax/java;frameworks/base/telecomm/java;frameworks/base/telephony/java;frameworks/base/phone/java;frameworks/base/wifi/java;frameworks/base/keystore/java;frameworks/base/rs/java:out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar:out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar: -d out/target/common/docs/api-stubs -hdf page.build LMY49M-eng..20170619.162734 -hdf page.now “”19 Jun 2017 16:29″” -knowntags ./frameworks/base/docs/knowntags.txt -hidePackage com.android.org.conscrypt -since prebuilts/sdk/api/1.xml 1 -since prebuilts/sdk/api/2.xml 2 -since prebuilts/sdk/api/3.xml 3 -since prebuilts/sdk/api/4.xml 4 -since prebuilts/sdk/api/5.xml 5 -since prebuilts/sdk/api/6.xml 6 -since prebuilts/sdk/api/7.xml 7 -since prebuilts/sdk/api/8.xml 8 -since prebuilts/sdk/api/9.xml 9 -since prebuilts/sdk/api/10.xml 10 -since prebuilts/sdk/api/11.xml 11 -since prebuilts/sdk/api/12.xml 12 -since prebuilts/sdk/api/13.xml 13 -since prebuilts/sdk/api/14.txt 14 -since prebuilts/sdk/api/15.txt 15 -since prebuilts/sdk/api/16.txt 16 -since prebuilts/sdk/api/17.txt 17 -since prebuilts/sdk/api/18.txt 18 -since prebuilts/sdk/api/19.txt 19 -since prebuilts/sdk/api/20.txt 20 -since prebuilts/sdk/api/21.txt 21 -werror -hide 111 -hide 113 -overview frameworks/base/core/java/overview.html -hdf sdk.version 4.4 -hdf sdk.rel.id 1 -hdf sdk.preview 0 -stubs out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src -api out/target/common/obj/PACKAGING/public_api.txt -removedApi out/target/common/obj/PACKAGING/removed.txt -nodocs

c:\Progra~2\Java\jdk1.7.0_80\bin\javadoc.exe -encoding UTF-8 @out/target/common/obj/JAVA_LIBRARIES/api-stubs_intermediates/droiddoc-src-list -J-Xmx512m -XDignore.symbol.file -quiet -doclet com.google.doclava.Doclava -docletpath out/host/windows-x86/framework/jsilver.jar

Perform necessary modifications in D:\Projects\Lollipop\platform\build\core\droiddoc.mk:

$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)\;$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
$(full_target): PRIVATE_CLASSPATH := $(subst $(space),\;,$(full_java_libs))

But still we have:

Docs droiddoc: out/target/common/docs/api-stubs
javadoc: error – Cannot find doclet class com.google.doclava.Doclava
1 error
out/host/windows-x86/framework/doclava.jar: out/host/windows-x86/framework/docla
va.jar: cannot execute binary file
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (3.:57. (mm:ss)) ####

Perform some modifications to D:\Projects\Lollipop\platform\build\core\droiddoc.mk.

Now we have:

including external/junit/Android.mk …
including packages/apps/ContactsCommon/Android.mk …
including packages/apps/Contacts/Android.mk …
including prebuilts/sdk/Android.mk …
make: Entering directory `/d/Projects/Lollipop/platform’
Docs droiddoc: out/target/common/docs/api-stubs
DroidDoc took 17 sec. to write docs to out/target/common/docs/api-stubs
make: Leaving directory `/d/Projects/Lollipop/platform’

still we have:

make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/android_s
tubs_current_intermediates/classes.jar’, needed by `out/target/common/obj/JAVA_L
IBRARIES/android-support-v4-api22_intermediates/classes-full-debug.jar’. Stop.

android_stubs_current_intermediates

Revise subdir:

subdir_makefiles := development/build/Android.mk external/tagsoup/Android.mk external/antlr/Android.mk external/jsilver/Android.mk external/doclava/Android.mk frameworks/support/v13/Android.mk frameworks/support/v4/Android.mk frameworks/support/v7/cardview/Android.mk external/jsr305/Android.mk external/guava/Android.mk frameworks/ex/common/Android.mk frameworks/opt/vcard/Android.mk frameworks/opt/net/voip/Android.mk frameworks/opt/net/ims/Android.mk frameworks/opt/telephony/Android.mk prebuilts/tools/common/guava-tools/Android.mk prebuilts/tools/common/asm-tools/Android.mk development/tools/rmtypedefs/Android.mk external/okhttp/Android.mk external/jarjar/Android.mk libcore/Android.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

Now we have:

make: Entering directory `/d/Projects/Lollipop/platform’
Compiling SDK Stubs: out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_
intermediates/classes.jar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/android-s
upport-annotations_intermediates/javalib.jar’, needed by `out/target/common/obj/
JAVA_LIBRARIES/android-support-v4-donut_intermediates/classes-full-debug.jar’.
Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

android-support-annotations

Modify subdir.

Now we have:

target Java: android-support-v4 (out/target/common/obj/JAVA_LIBRARIES/android-su
pport-v4_intermediates/classes Compile with javac -J-Xmx256m -source 1.7 -target
1.7 -Xmaxerrs 9999999 and parameter -bootclasspath out/target/common/obj/JAVA_L
IBRARIES/sdk_v4_intermediates/classes.jar on out/target/common/obj/APPS/Contacts
Tests_intermediates/classes-full-debug.jar )
frameworks\support\v4\java\android\support\v4\accessibilityservice\Accessibility
ServiceInfoCompat.java:106: error: cannot find symbol
return AccessibilityServiceInfoCompatJellyBeanMr2.getCapabilities(in
fo);
^
symbol: variable AccessibilityServiceInfoCompatJellyBeanMr2
location: class AccessibilityServiceInfoJellyBeanMr2
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
make: *** [out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates
/classes-full-debug.jar] Error 41
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (1.:26. (mm:ss)) ####

bash-3.1$

out/target/common/obj/JAVA_LIBRARIES/android-support-v4_intermediates/classes-full-debug.jar

This is caused by malformed file name again:

redownload and extract with gzip and tar command line, we have:

target Static Jar: android-support-v7-cardview (out/target/common/obj/JAVA_LIBRA
RIES/android-support-v7-cardview_intermediates/javalib.jar)
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/android-s
upport-v7-palette_intermediates/javalib.jar’, needed by `out/target/common/obj/A
PPS/Contacts_intermediates/classes-full-debug.jar’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

out/target/common/obj/JAVA_LIBRARIES/android-support-v7-palette_intermediates/javalib.jar

Revise subdir:

subdir_makefiles := frameworks/support/v7/palette/Android.mk frameworks/support/annotations/Android.mk development/build/Android.mk external/tagsoup/Android.mk external/antlr/Android.mk external/jsilver/Android.mk external/doclava/Android.mk frameworks/support/v13/Android.mk frameworks/support/v4/Android.mk frameworks/support/v7/cardview/Android.mk external/jsr305/Android.mk external/guava/Android.mk frameworks/ex/common/Android.mk frameworks/opt/vcard/Android.mk frameworks/opt/net/voip/Android.mk frameworks/opt/net/ims/Android.mk frameworks/opt/telephony/Android.mk prebuilts/tools/common/guava-tools/Android.mk prebuilts/tools/common/asm-tools/Android.mk development/tools/rmtypedefs/Android.mk external/okhttp/Android.mk external/jarjar/Android.mk libcore/Android.mk external/conscrypt/Android.mk external/bouncycastle/Android.mk frameworks/base/core/res/Android.mk frameworks/base/Android.mk external/junit/Android.mk packages/apps/ContactsCommon/Android.mk packages/apps/Contacts/Android.mk prebuilts/sdk/Android.mk

We have:

Copying: out/target/common/obj/APPS/Contacts_intermediates/classes-jarjar.jar
Copying: out/target/common/obj/APPS/Contacts_intermediates/emma_out/lib/classes-
jarjar.jar
Copying: out/target/common/obj/APPS/Contacts_intermediates/classes.jar
make: *** No rule to make target `external/proguard/bin/proguard.sh’, needed by
`out/target/common/obj/APPS/Contacts_intermediates/proguard.classes.jar’. Stop.

make: Leaving directory `/d/Projects/Lollipop/platform’

Download from:

https://android.googlesource.com/platform/external/proguard/+/android-5.1.1_r38

We have:

Proguard: out/target/common/obj/APPS/Contacts_intermediates/proguard.classes.jar

ProGuard, version 4.10
Reading input…
Reading program jar [D:\Projects\Lollipop\platform\out\target\common\obj\APPS\Co
ntacts_intermediates\classes.jar]
Reading library jar [D:\Projects\Lollipop\platform\out\target\common\obj\JAVA_LI
BRARIES\core-junit_intermediates\classes.jar]
Reading library jar [D:\Projects\Lollipop\platform\out\target\common\obj\JAVA_LI
BRARIES\core-libart_intermediates\classes.jar]
Reading library jar [D:\Projects\Lollipop\platform\out\target\common\obj\JAVA_LI
BRARIES\ext_intermediates\classes.jar]
Reading library jar [D:\Projects\Lollipop\platform\out\target\common\obj\JAVA_LI
BRARIES\framework_intermediates\classes.jar]
Reading library jar [D:\Projects\Lollipop\platform\out\target\common\obj\JAVA_LI
BRARIES\telephony-common_intermediates\classes.jar]
Reading library jar [D:\Projects\Lollipop\platform\out\target\common\obj\JAVA_LI
BRARIES\voip-common_intermediates\classes.jar]
Initializing…
Ignoring unused library classes…
Original number of library classes: 11333
Final number of library classes: 11333
Shrinking…
Removing unused program classes and class elements…
Original number of program classes: 3195
Final number of program classes: 1222
Writing output…
Preparing output jar [D:\Projects\Lollipop\platform\out\target\common\obj\APPS\C
ontacts_intermediates\proguard.classes.jar]
Copying resources from program jar [D:\Projects\Lollipop\platform\out\target\c
ommon\obj\APPS\Contacts_intermediates\classes.jar]
make: *** No rule to make target `out/host/windows-x86/bin/dx’, needed by `out/t
arget/common/obj/APPS/Contacts_intermediates/with-local/classes.dex’. Stop.
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make failed to build some targets (56 seconds) ####

bash-3.1$

Download from:

https://android.googlesource.com/platform/dalvik/+/android-5.1.1_r38

make: Entering directory `/d/Projects/Lollipop/platform’
host Java: dx (out/host/common/obj/JAVA_LIBRARIES/dx_intermediates/classes)
warning: [options] bootstrap class path not set in conjunction with -source 1.6
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
Install: out/host/windows-x86/framework/dx.jar
Copy: dx (out/host/windows-x86/obj/EXECUTABLES/dx_intermediates/dx)
Notice file: dalvik/dx/NOTICE — out/host/windows-x86/obj/NOTICE_FILES/src//bin/
dx.txt
Install: out/host/windows-x86/bin/dx
target Dex: Contacts
Copying: out/target/common/obj/APPS/Contacts_intermediates/classes.dex
make: *** No rule to make target `out/host/windows-x86/framework/signapk.jar’, n
eeded by `out/target/product/generic/obj/APPS/Contacts_intermediates/package.apk
‘. Stop.

We have:

target Package: Contacts (out/target/product/generic/obj/APPS/Contacts_intermedi
ates/package.apk)
warning: string ‘add_field’ has no default translation.
warning: string ‘add_field’ is missing 87 required localizations: af_ZA am_ET ar
_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_C
A en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi_FI fr_BE
fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_IT iw_IL ja
_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN mn_MN mr_I
N ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO ru_RU si_LK
sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_PK uz_UZ vi
_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘contact_detail_picture_description’ has no default translation.

warning: string ‘contact_detail_picture_description’ is missing 87 required loca
lizations: af_ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_
DE de_LI el_GR en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE
eu_ES fa_IR fi_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID i
s_IS it_CH it_IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_
LV mk_MK ml_IN mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT
rm_CH ro_RO ru_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH t
r_TR uk_UA ur_PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘contactsAllLabel’ has no default translation.
warning: string ‘contactsAllLabel’ is missing 87 required localizations: af_ZA a
m_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_
AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi_FI
fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_IT i
w_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN mn_
MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO ru_RU
si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_PK u
z_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘contactsGroupsLabel’ has no default translation.
warning: string ‘contactsGroupsLabel’ is missing 87 required localizations: af_Z
A am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR
en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi
_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_I
T iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN
mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO ru
_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_P
K uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘description_dial_phone_number’ has no default translation.
warning: string ‘description_dial_phone_number’ is missing 87 required localizat
ions: af_ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de
_LI el_GR en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_E
S fa_IR fi_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS
it_CH it_IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk
_MK ml_IN mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_C
H ro_RO ru_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR
uk_UA ur_PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘description_send_message’ has no default translation.
warning: string ‘description_send_message’ is missing 87 required localizations:
af_ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI e
l_GR en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_
IR fi_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH
it_IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK m
l_IN mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_
RO ru_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA
ur_PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘no_contact_details’ has no default translation.
warning: string ‘no_contact_details’ is missing 87 required localizations: af_ZA
am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR e
n_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi_
FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_IT
iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN m
n_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO ru_
RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_PK
uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘people’ has no default translation.
warning: string ‘people’ is missing 87 required localizations: af_ZA am_ET ar_EG
az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA e
n_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi_FI fr_BE fr_
CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_IT iw_IL ja_JP
ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN mn_MN mr_IN m
s_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO ru_RU si_LK sk_
SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_PK uz_UZ vi_VN
zh_CN zh_HK zh_TW zu_ZA
warning: string ‘percentage’ has no default translation.
warning: string ‘percentage’ is missing 87 required localizations: af_ZA am_ET a
r_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_
CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR fi_FI fr_BE
fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_IT iw_IL j
a_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN mn_MN mr_
IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO ru_RU si_LK
sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_PK uz_UZ v
i_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘use_photo_as_primary’ has no default translation.
warning: string ‘use_photo_as_primary’ is missing 87 required localizations: af_
ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR
en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR f
i_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it_
IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_IN
mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO r
u_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur_
PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
warning: string ‘viewContactDesription’ has no default translation.
warning: string ‘viewContactDesription’ is missing 87 required localizations: af
_ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_G
R en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR
fi_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it
_IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_I
N mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO
ru_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur
_PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
/bin/bash: /c/Progra~2/Java/jdk1.7.0_80/bin/jar: Bad file number
make: *** [out/target/product/generic/obj/APPS/Contacts_intermediates/package.ap
k] Error 126
make: *** Deleting file `out/target/product/generic/obj/APPS/Contacts_intermedia
tes/package.apk’
make: Leaving directory `/d/Projects/Lollipop/platform’

out/target/product/generic/obj/APPS/Contacts_intermediates/package.apk:

Error is located at:

$(add-carried-java-resources)

The proper command is:

D:\Projects\Lollipop\platform>jar uf out/target/product/generic/obj/APPS/Contact
s_intermediates/package.apk out/target/product/generic/obj/APPS/Contacts_interme
diates/java_res_jar_flags

Modify D:\Projects\Lollipop\platform\build\core\definitions.mk

At last we have:

warning: string ‘viewContactDesription’ has no default translation.
warning: string ‘viewContactDesription’ is missing 87 required localizations: af
_ZA am_ET ar_EG az_AZ bg_BG bn_BD ca_ES cs_CZ da_DK de_AT de_CH de_DE de_LI el_G
R en_AU en_CA en_GB en_IN en_NZ en_SG en_US eo_EU es_ES es_US et_EE eu_ES fa_IR
fi_FI fr_BE fr_CA fr_CH fr_FR gl_ES hi_IN hr_HR hu_HU hy_AM in_ID is_IS it_CH it
_IT iw_IL ja_JP ka_GE kk_KZ km_KH kn_IN ko_KR ky_KG lo_LA lt_LT lv_LV mk_MK ml_I
N mn_MN mr_IN ms_MY my_MM nb_NO ne_NP nl_BE nl_NL pl_PL pt_BR pt_PT rm_CH ro_RO
ru_RU si_LK sk_SK sl_SI sr_RS sv_SE sw_TZ ta_IN te_IN th_TH tl_PH tr_TR uk_UA ur
_PK uz_UZ vi_VN zh_CN zh_HK zh_TW zu_ZA
make: Leaving directory `/d/Projects/Lollipop/platform’

#### make completed successfully (59 seconds) ####

How to Perform Separate Assets Download of The Sims FreePlay

November 14, 2015

If you have obtained this Android game and want to use it for a first time, mostly it will show the “Update Check” information box as below:

Clipboard01

It is often failed at this stage because the amount of download file is rather large, for example, my device is around 450 MB.

So then you will try to find the files to be downloaded using the net by searching “APK + Data” or by other means, only to find that the application failed to load, ending in an abrupt stop.

The reason why it failed is because each phones requires specific asset and if the downloaded assets is not compatible for your Android Phone.

In fact, when the Update Check is in progress, the download module of the program will try to obtain the correct asset package by supplying your phone device information and your graphics processor capabilities.

This information is sent to the game server, and the server will provide the list of zip files to be downloaded based on information supplied by the downloader.

Because the assets to be downloaded is rather big, that’s why the module will provide some warning if you try to download the files using mobile data quota and prefer using WiFi instead.

Sometimes, even if you prepare to download directly from your phone, the download manager will failed showing the error box as follows:

Clipboard02

The message “A Server error has occurred. Please visit http://www.eamobile.com/countrygate, etc” means this is the end for you to ever play this game on your phone.

So, why not using your PC and existing cable internet to download the file ? It is possible by providing the steps that will be described below.

First is to create the debug.enable file and placed it in the root directory of your phone’s sdcard. The content of this file doesn’t matter, because the program will only checks for this file for deciding it will write the debug information to tell you the internal workings of the downloading module.

Once you have place this file, try to run the program again, and after that if you are lucky :), you will find the presence of debug.txt in your root directory of sdcard.

Inside this file is the list of correct assets in the form of zip files according to your installed The Sims FreePlay program.

At this point, you can download the above list of zip files, and extract place it in the program’s data folder, for example Android/data/com.ea.games.simsfreeplay_na. Be sure to provide the correct folder structure. In my case, of the assets is placed under the /published folder.

There are one more step to perform, i.e. to tell the download module that you are already provide the files, so don’t bother to perform redundant work for you.

You have to supply two files, i.e. Downloaded.indicate and Downloaded2.indicate, and place it in the program’s data folder above. This is just a text file.

The content of Downloaded2.indicate is a list of downloaded file, for example adc_v3.7.7_chunk01_GoogleGroup3.zip. You have to place one of those zip file in the program’s data folder, but not all of them, just one file to provide the evident to the downloader so as to make it satisfied.

So, inside download Downloaded2.indicate, you type the downloaded file string, for example adc_v3.7.7_chunk01_GoogleGroup3.zip and saves it as text file, placed it in the data folder.

For Downloaded.indicate, you have to type information as follows:

COMPLETE
Version[VERSION INFO]

for example:

COMPLETE
Version4.5.1

You have to create the higher version from the one supplied in the debug.txt file. Between the Version and the version number is separated by the TAB character.

Placed it in the data folder and pray before executing your favorite game again, it should works πŸ™‚

How to Activate OpenGLES 2.0 in Android Emulator

October 24, 2015

Most of the Application Developers who wants to learn basics of OpenGLES architecture will find and try to execute the Hello OpenGLES sample provided by Android.

And there are two variants of the sample, one for OpenGLES version 1 and the other, OpenGLES version 2. So, almost everyone try to use the version 1 will successfully run the sample, and nearly all will fails for version 2 on first try.

If you try to search in the net of how to resolve the version 2 problem, you will find there are many confusing stories, that will cause frustration and will believe that OpenGLES version 2 is not supported in the emulator.

There are also suggestion to call setEGLConfigChooser, but it requires right condition to be effective.

The key is to pay attention to the log file given by the emulator during start up. Here is the indication that something wrong for OpenGLES 2.0 support in the emulator:

ge01

Emulator can still be run at this condition, and this will have some effect at the Android application side, which some indication in the logcat as follows:

ge02

If the Android Framework is forced to use libGLES_android.so, then it is game over. You will be stuck in OpenGLES version 1 forever. The setEGLConfigChooser will useless, because the error will be triggered at Android GL java runtime before the setEGLConfigChooser is executed. Usually the error message is “No configs match configSpec”.

If you get the above error message, this indicated that your emulator is still using libGLES_android.so and only can operate in OpenGLES version 1.

Here, you should make sure that the emulator is capable to support version 2 by eliminating the above error message from emulator by supplying the requested DLL. But part of the difficulty lies in the error message from emulator which is rather un-informative.

The missing DLL is actually libOpenglRender.dll and this dll also requires other dll. So, please make sure that libGLES_V2_translator.dll, libGLES_CM_translator.dll and libOpenglRender.dll is present in the same directory as the emulator program.

Sign of healthy emulator that’s ready for OpenGLES 2.0 support is indicated by the log below:

ge03

You can notice that emulator now adds new switch called qemu.gles with 1 as its value. This will cause the Android Framework to use different library because it checks the presence of ro.kernel.qemu.gles and if the value is 1 it will use different library set as indicated by the log below:

ge04

But the Hello OpenGL ES 2.0 still have some problem with “no config chosen” error:

ge05

Let’s retrieve the logcat:

ge06

Here’s the logcat result:

ge07

To get more information about the nature of the error, I’ve created the Netbeans project for existing Android Java Framework as follows:

ge08

Adds the source package from starting at D:\Projects\Android\Frameworks\Base\opengl\java

ge09

Should set the application to stop execution waiting for debugger:

ge10

Execute the application, we will have this screen:

ge11

Examine the process attribute and noted down the PID:

ge12

Perform port forwarding for the noted PID value:

ge13

In Netbeans attach to the process:

ge14

Now it will stopped at intended breakpoint:

ge15

So the problems lies inside chooseConfig on GLSurfaceView.java which insist on getting config with satisfying mAlphaSize is zero. All of the available alpha size from the emulator is 8.

So why this mAlphaSize is created with zero value ? To find it, here is the call stack at the time of class instance call:

ge16

And the function call appears to be hardcoded:

ge17

Here the call to setEGLConfigChooser will get some effect this time, because it will override the default one given by the Framework:

ge18

Perform re-compilation:

ge19

Re-installation process:

ge20

See that it can be run this time:

ge21

Q.E.D πŸ™‚

Experiences in Debugging Non-Symbol Android Shared Library

September 19, 2015

The shared library which shipped with the Android’s APK file usually do not have the symbol file. And if the application stopped working, usually it is related to problems in the shared library. To perform a detailed information of why it is not working, one of the method is to perform a debugging session.

But unfortunately, some game vendors will creates some measures to make the debugging process very difficult.

I will include an analysis of lib__57d5__.so, which is part of popular Final Fantasy game, which is failed to execute in my android device. In my case, it is used in Final Fantasy IV.

When I try to launch the program in the emulator, nothing happened and the screen just goes back to the launcher. Let’s see what the content of the last log activities:

dd01

From the above log, it is identified that the main program is located at BootActivity, and there’s also an attempt to load the lib__57d5__.so. The cause of the abrupt stop without any message is because the program is exceeding the App freeze timeout value.

To get more information about BootActivity class, the apk should be decompiled, and the decompiled source at clinit constructor of BootActivity as follows:

dd02

Inside the clinit of MainActivitya class as follows:

dd03

Let’s try to load this library independently by creating the small program called hello and see the mechanisms during its loading process.

dd04

But after running this program, it shows “Loading Library” and then, nothing, not even a message that inform that it has failed to load the library.

dd05

Try to checks the logcat for any message reveals nothing. So let’s perform it in a debugging session:

dd06

You can see from the above debugging session that there is “File truncated” error and there are no information about the address boundary of the loaded library.

If I try to perform object dump of the library I have:

dd07

Let’s use another tool called readelf:

dd08

You can see that the developer of this mysterious library is also try to thwart the attempt to perform some dump of the library content and also debugging attempt. The only information I can get from the library is the start up routine as follows:

dd09

Depending on memory state on your machine, the start up address may different. In my case, it is located at 0xb6edc3a5 (value marked with green color above).

This address is important to perform some calculation later at this article.

So, when I try to get some more clue, I’ve notice the presence of __57d5__.log file inside /sdcard directory, which should be created from the loaded library. Let’s pull it for more examination:

dd10

The content of this log file as follows:

dd11

The error code is originated from r5 registers at the time of __errno call:

dd12

This can be proved by setting the r5 value to some other one, for example 70 below, and the content of the error code log will change from 60 to 70

dd13

When the r5 register is filled with error code = 60 ? To provide the answer to this question, it is necessary to perform debugging at the vicinity of the above stack trace of 0xb6f1612a. This value can be deduced from the start up routine location, obtained at library load event as follows:

dd14

Now, let’s stop again at the loading event of lib__57d5__.so, by examining the r4 register in the using the above method I have:

dd15

Examining the code at this location, I have:

dd16

This shows a gibberish data and clearly is not a normal arm instruction code. Let’s repeat the above step by breaking into __errno function and examine the callstack:

dd17

Now the above code location magically transformed into an arm instruction code. Try to perform breakpoint at this location also proves to be futile because it will instantly cause the SIGILL exception.

So, it is necessary to obtain the routine that changes the data at this specific location that transform the encrypted data to a workable arm instruction.

The location in question, examined using hex form is:

dd18

Change detection can be performed by performing memory access read when the emulator is inside WinDBG debugger. When it can be identified, the decryption routine can be deduced from program counter when the breakpoint is triggered. From here, this can be expanded and overall decryption routine can be analyzed.

The decryption process depends on the right key and it is calculated from the range of the encryption block. If any of the block range contains breakpoint instruction (i.e. 0xDE01 for thumb instruction), it will make the decryption key invalid and decoded encrypted instructions will be incomprehensible.

There are two blocks of encrypted routines and the first block will decrypt yet another core block which perform some checks that will cause the error 60 above.

So, in order to perform debugging for this library, the first task is to place the breakpoint just before the decryption routines, adjust the right key, place another breakpoint after decryption routine and after that you are safe to place any breakpoint inside the decrypted routine for further examination.

Here, the error code 60 means that the ro.hardware property string contains goldfish (i.e. the machine is goldfish) or if it is running inside the emulator (i.e. by checking the ro.kernel.qemu property string).

If it is not on either one above, the library may returned with error code 40, if it detects TracerPid is non zero. This is used to check whether the library is running under debugging mechanism.

If the library is not being debugged, it will return error code 1 if it not detecting the presence of /system/bin/app_process or /system2/bin/app_process in the /proc/self/status value. This means that the library is not running under Android Application Framework (i.e. runs the program from the Top Launcher Menu).

Later on, it will checks the user id that calls this library and when it is a root user (AID_ROOT) or AND_NOBODY, i.e. not identifed as AID_APP user ID which is 10000 and above, it also returns with error code 1.

The error code 1 can also mean that certain libary required for this library to be functioning properly is not found on the process space, for example /system/lib/libdvm.so.

If you found that you have still get the error even when the above basic checks, the starting point is to examine the error code inside the log file given by the library, performing the debugging process by decrypting using the right key πŸ™‚

How Compile Android Goldfish Kernel on Windows OS

July 16, 2015

This article will chronicle the events that happening during the session of compiling Android Goldfish kernel on windows environment. It is hoped that by the end of this article, you can also repeat this experiment successfully.

Host machine is Windows 7, with installed MINGW GCC 4.7.2 and latest version of CYGWIN. The goldfish kernel source already has the makefile, so it seems do not requires the configuration phase.

After everything is ready, kernel configuration phase is done by calling the make as follows:

kn01

The first impression is the crashed GCC compiler as informed by the OS:

kn02

To perform tracking of the above error message, it is necessary to creates basic framework to print-out processed value into the make log file. This is done by creating basic script as follows:

kn03

Using the above construct, the output when done using -p command:

kn04

The output will show:

kn05

So, the causes of the above crash is originated from script execution of:

kn06

After isolating the execution script inside the above makefile, I arrived at one of the many troubling scripts that has patterns as follows:

kn07

Which calls to cc-option in Kbuild.include with the prototype as follows:

kn08

And the try-run function as follows:

kn09

The above scripts try to probe the compiler for presence of specific compiler flags, and perform necessary setup for the starting the compilation phase.

The above constructs will causes the compiler to crash, but, what exactly the cause of this ? To perform more examination, I’ve created the test script (let’s call it testmk) that contains the related functions and try to simplifies the output and do not perform any silencing options as follows:

kn10

Here is the output when the above script is executed:

kn11

After the above message, the compiler will try to find non-existent file and will caused it to crash. Hence the above crash message box is shown.

So, the problems is malformed temporary file name string. After trying some ways to fix this without success, I decided to evade the using of temporary file inside the shell chain of command. Instead, I’m using the temporary file outside the the call. For example as follows:

kn12

Then the script temporary file creation is removed to become:

kn13

The crashes is now gone, but I arrived at another error as follows:

kn14

This is because there’s a command in the makefile script as follows (by viewing the myTesting.txt file):

kn15

Which translates to (using procmon.exe):

kn16

Functions inside fixdep.c is specific to Linux OS and MINGW still can’t handle it, so it is necessary to use Cygwin’s compiler instead of MINGW GCC by modifying the makefile scripts at specific location (in Makefile.host). This should be done for other host specific programs:

kn17

Re-run the make program, the configuration phase seems to work, Now:

kn18

This is because the ln.exe in MSYS is broken, so after I use the alternate one in Cygwin the symbolic link sucessfully created. Now, I have:

kn19

This is because compiled dependency file created by arm compiler on windows contains CR (Carriage Return) characters, so fixdep.c is broken because in its native environment do not recognize CR character, so perform small changes to the source will fix this. Now I have:

kn20

Now the make script complained that it can not create the file inside include/asm. Seems that the symbolic link is created all right but it is useless, because Windows OS do not recognize it.

What’s the solution ? I should use the native command of windows MKLINK and remove the previously written symbolic link:

kn21

But now the make scripts complains that ERROR: $@ is a directory but a symlink was expected, which is contrary to the philosophy of current situatuon, because the directory is what should be expected on windows OS.

The solution is to modify make script inside Makefile at the kernel Goldfish’s root directory for check-symlink function by removing the exit 1 command and turning the error into a warning. The second step is to modify the output destination that lacks the windows path separator by adding ./ character into the start of the created file inside Kbuild’s cmd_offsets command of writing the asm-offsets.h.

Re-run the make file script and after some long series of kernel compilation process, I arrived at:

kn22

Searching through the net for solution of unknown CPU architecture error again proves to be futile. I wonder where are those android developers are going regarding this issue. Seems that nobody in all of android developer community cares about this crucial thing.

Since there is almost no hope to find solution from the crowd source, I decided to investigate this issue further by myself. First thing first, is to isolate the problem, so I don’t have to repeat the lengthy process of make and also for faster problem solution.

So, here is the issue:

kn23

The toolchain’s LD utility tries to creates the vmlinux image from several object files, one of which is piggy.o. This object is derived from piggy.S and piggy.gz. piggy.gz is actually a compressed form of arch/arm/boot/Image, where as piggy.S contains source for locating the compressed image using input_data and input_data_end label.

If I combine head.o and misc.o, I also receives unknown CPU architecture as follows:

kn24

The error message is the same with combined head.o and piggy.o. Seems that combining any other object file with either piggy.o and head.o will break the linker. To prove it, I perform some test case, by bringing in more object files, let’s call it myTesting1.o and myTesting2.o that can be successfully linked as follows:

kn25

There are no error which indicates linking is a success. This also verify that both myTesting1.o and myTesting2.o is a valid object files.

So let’s combined it with misc.o with myTesting1.o:

kn26

Well, still no error. So what about combining head.o with myTesting1.o:

kn27

Since we already know that myTesting1.o is a valid object file, the above error message from linker that points the error at myTesting1.o is misleading, and the actual problem is the object file that is combined with myTesting1.o, which should be head.o.

Same error by combining piggy.o with myTesting1.o.

What differentiates between those two renegades with the other object files ? Here’s a dump of readelf utility for head.o:

kn28

And the dump of misc.o:

kn29

After performing detailed examination of compilation script for head.o and piggy.o, the cause of differences in Tag_CPU_arch names on those objects is caused by presence of -march=all switch. Apparently the linker refuse to accept that Tag_CPU_arch should be all for the kernel image.

So, the head.o and piggy.o should be compiled manually by removing the troubling switch, and one last step should be done manually:

kn30

To use the zImage for the emulator, copy the image to C:\Android\sdk\system-images\android-19\armeabi-v7a, backup the existing kernel-qemu file and rename the zImage to kernel-qemu.

Here is the kernel in action:

kn31

How to Solve Android Kernel Panic

July 16, 2015

In the course of studying a library compiled in Android’s ARM platform, I came across this message upon activating the Android ARM OS inside the emulator as follow:

panic01

The error Kernel panic – not syncing is happening at boot time, and I have the stack trace as follows:

panic02

I can say that the above stack trace is rather useless, because it doesn’t show what causes it, it only shows the order the signal is processed.

The only useful info is only the signal code, in the error message is called exitcode=0x0000000b. This code is actually a SIGSEGV, and certainly there are some modules of functions that triggers this signal.

To find what module that causes the signal, it is necessary to examine the android kernel, and mine is inside android goldfish kernel source. There are several candidates that trigger the SIGSEGV signal, such as force_sig, force_sigsev, arm_syscall, etc. This should be eliminating one by one until leaving the only one that verified to be actually executed.

So how to perform the verification process for each candidate function ? Again use the kallsyms and the modified android emulator to the rescue. You can consult to the previous article on how to perform physical breakpoint to the kernel function of interested.

The elimination process leaves the do_page_fault kernel function as the causes of SIGSEGV. But to arrive at the condition of really triggering SIGSEGV in the function flow, it is necessary to examine whether it actually calls __do_page_fault function.

Unfortunately, the __do_page_fault is not listed in kallsyms, so I should find another alternatives for tracing the function flow. By examining the function flow inside do_page_fault, by discounting the __do_page_fault, there are two more calls to be examined, i.e. __do_kernel_fault and __do_user_fault.

But examining the __do_kernel_fault at source level convinced me it is unlikely to be get called, because it leads to a very different kernel error message as shown at the start of this article.

This leaves only __do_user_fault, and it is indeed gets called. This is the register state at the start of the function:

panic03

This is the prototype of the function:

panic04

There are many false faults in the Android system because, it use the fault mechanism as means for doing some other correction routines, such as memory allocation for example.

Notice the R3 value contains 11 (0x0B) is the kernel code for SIGSEGV.

To differentiate between the real and false one, it is necessary to perform register examination at the start of __do_user_fault. Here is the real one:

panic05

At the start of __do_user_fault function, R11 register contains fault code, in this case 0x65536 is VM_FAULT_BADMAP. And the requested address is at R4 register which is 196608 = 0x30000. And the system will stop by sending kernel panic and halted.

So why those specific memory causes a fault ? To answer this question, it is necessary to provide complete emulator execution log, so that I can locate the exact position of the error.

By examining the result of generated qemu-log, I’ve found the strange execution patterns as follows (i.e. moments before the system crashes):

panic06

Seems like the emulator is encountering an endless loops and keep continuing until it hit at some memory boundary and causes the un-recoverable fault. This is evident by examining the next pc which located at 0xC0031C1C. This address is in the vicinity of do_page_fault function trap and will call __do_user_fault when it gives up after trying the recovery routines.

By tracing the above run away execution log up to the starting point, I notice the anomaly as follows:

panic07

Instead of performing unconditional jump to the requested address, it just keeps executing the instruction below, just like it is blind that the instruction were there.

In the end, after examining the emulator’s source code, I notice that in the course of modifying the routine inside disas_thumb_insn (translate.c), I accidentally remove the cpu_lduw_code statement, so the instruction is not get processed when the Android OS switches to thumb mode.

The cause is so simple, but the effect is enormous and almost impossible to find out, like finding needle in a haystack the size of football field.

And when it is happening in the middle of some deadline, it will surely cause a panic attack, as suggested by Android’s Linux OS kernel message πŸ™‚

Solving SIGILL in Android Emulator Debugging for Thumb Mode

June 14, 2015

In my previous article, I’ve indicated that there are still more SIGILL even though it is already resolved for pure arm instructions. The gdb client still has some shortcomings on handling the arm thumb instructions.

Suppose I’ve compile the hello program in the thumb mode. The SIGILL still crops up, when I try to use the program as it is without the aid of symbol file:

tb01

So, the debugger client can’t be use for debugging non symbol application with the thumb instruction in it. Close examination of the above problem reveals that determination whether current given program counter is in thumb or arm mode is inside arm_pc_is_thumb (arm-tdep.c) function. It fails to detect whether code at given program counter (pc) is in fact a thumb instruction.

More detailed analysis reveals that it tries to infer the thumb mode state by checking the cpsr register through frame_unwind_register_value (frame.c) function, which returns unpredictable cpsr state, especially when the transition is from either the two modes.

To remedy this situation, you can set the fallback-mode to either thumb or arm, depending on the current breakpoint location and its code characteristics. In other words, the information about the modes is determined by the user.

tb02

Don’t forget to set the appropriate mode when you eventually arrive back at arm instruction.