Archive for the ‘Android’ Category

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.

Solving SIGILL in Android Emulator Debugging

June 14, 2015

Now I have required components that would hopefully provide some insights into causes of SIGILL in Android emulator debugging. So, this bug still exist, even with the latest version (v7.7):

sv01

Instruction code at address 0x000082FC should be 0xe08f3003, but gets written to 0xEF9F0001. So, let’s perform debugging of the gdb client for the origin of this value. Just before executing si command, perform breakpoint at putpkt_binary at client program:

sv02

After performing several continue instruction in the debugger, we have:

sv03

Verify the buf value:

sv04

Indeed the invalid instruction, but where the buf value came from ? Let’s view the partial callstack that leads to this condition:

sv05

Examining the memory at 0x681e35, we have:

sv06

Prototype function target_write_raw_memory as follow:

sv07

It is called by default_memory_insert_breakpoint function using parameters as follow:

sv08

So, the 0xEF9F0001 is actually bp variable passed to the target_write_raw_memory function, whereas bp variable itself is retrieved from gdbarch_breakpoint_from_pc function as follow:

sv09

Inside this function, it is only a stub, with the instruction to return the value of:

sv10

In arm architecture, this is actually a call to arm_breakpoint_from_pc function:

sv11

After more thorough examination in this style, finally I arrived at the conclusion that the value is retrieved from arm_breakpoint field of tdep structure in arm architecture:

sv12

tdep is given by gdbarch_tdep structure as follow:

sv13

arm_breakpoint is initialized at arm_linux_init_abi function with arm_linux_arm_le_breakpoint. But why the ordinary breakpoint seems working without causing SIGILL ?

sv14

0xE7F001F0 is actually an eabi_linux_arm_le_breakpoint (for little endian style). On my emulator, this instruction is passed as an illegal operation. This is verified by the procedure described below:

sv15

In my compiled version of Android Emulator, I’ve created the dummy instruction inside disas_arm_insn function (pictured above) and perform filling out the inv_insn value with the 0xE7F001F0 = 3891266032 and perform break:

sv16

Stepping through this function has confirmed that it is indeed passed as an illegal instruction.

So, does this instruction is get trapped by the Android kernel ? To prove this, I replace the instruction in hello main routine with 0xE7F001F0 (techniques I explained in previous article), I receive:

sv17

Signal 5 is actually a SIGTRAP (signal.h)

But with 0xEF9F0001, I receive:

sv18

This means that for my version of Android kernel, it recognizes only 0xE7F001F0 as a legal breakpoint instruction that can be inserted into the codes.

To prove this conjecture, I’ve perform several testing session, and each SIGILL event is always preceeded by presence of writing 0xEF9F0001 instruction to the address space of emulator.

But the server also detected presence of 0xE7F001F0 instruction writing from the client. So, let’s examine the callstack again at this event:

sv19

By comparing the callstack sequence, the difference lay between the call to function deprecated_insert_raw_breakpoint and bkpt_insert_location. The previous one causes SIGILL, but later one do not.

Let’s perform more close examination of arm_breakpoint value at the bkpt_insert_location function call:

sv20

This is the partial callstack below bkpt_insert_location function, for the purpose of tracing the origin of bl structure initialization:

sv21

By analyzing functions in this callstack chain, it is revealed that the breakpoint mechanism relies on global static structure **bp_location at breakpoint.c.

To the origin of arm_breakpoint value, it is necessary to find when bp_location structure is initialized. Since my current gdb for windows fails to perform a decent memory write breakpoint, I have to resort to WinDBG by first obtaining the correct address from gdb symbol file:

sv22

Then in my WinDBG session:

sv23

There is an allocation call at the 0x0048289F location just before bkpt_insert_location call, and the memory that’s allocated is identical with the initialized bp_location value at the time of bkpt_insert_location which gives the working arm breakpoint value. Let’s perform close examination at this state.

Just after the call to update_global_location_list before bkpt_insert_location, here is the state of bp_location and its associated gdbarch and tdep structure:

sv24

This value is identical and hence is being used at the time of bkpt_insert_location call:

sv25

By examining the source code at bp_location initialization:

sv26

The bp_location is actually assigned from breakpoint_chain->loc value:

sv27

In order to find when and how the loc value is assigned, the above memory write breakpoint for bp_location is repeated for breakpoint_chain, we have:

sv28

Location at 0x00486a17 is inside install_breakpoint which calls to add_to_breakpoint_chain function and is assigned from the function parameter b of type breakpoint structure:

sv29

The b breakpoint structure is initialized inside create_breakpoint_sal, and by examining the routine steps, the breakpoint structure and it’s associated loc variable is actually assigned at init_breakpoint_sal call. To find the initialization event of loc structure, it is necessary to view the low level structure of b to be used for memory write breakpoint at WinDBG:

sv30

And also code location just before init_breakpoint_sal:

sv31

And precise address of b:

sv32

Now activates WinDBG, points to the above specified address and perform memory write breakpoint at the appointed location, we have:

sv33

The edi register value contains the initialized loc variable and the above address location is inside add_location_to_breakpoint function. Value of interest inside this function is loc_gdbarch, and it can be seen below, is retrieved from get_sal_arch. It is interesting that it is not used the original gdbarch value provided by b structure which contains arm breakpoint value that causes SIGILL. It uses original gdbarch from b structure only when the function returns null value:

sv34

Let’s verify this value to confirm that the function is a success:

sv35

The function is a success because it uses a different value for gdbarch structure provided by the one inside b structure. The get_sal_arch function depends on get_objfile_arch (objfiles.c) to determine the architecture. This function in turn gets the archtecture info from provided obj file. This explains why sometimes the breakpoint works and sometimes causes SIGILL.

Now, let’s perform breakpoint without the aid of symbol file:

sv36

Instead of stopping properly at requested address, the debugger receives a SIGILL signal.

Let’s perform breakpoint again at install_breakpoint for the above condition and examine its arm_breakpoint value:

sv37

Further checks for arm_breakpoint value is not necessary because it is clearly that gdbarch value is given by default value, which is 0x2d00280. This value is passed as parameter in the above callstack. We have already verified that for default value, arm_breakpoint will contain 0xEF9F0001 that is not recognized as valid breakpoint value at my Android Emulator and causes SIGILL signal.

Using this fact, if I somehow managed to perform revision on the gdb client program so that the default gdbarch will deliver the recognized breakpoint, then the SIGILL signal can be avoided. But first, it is necessary to find out how this value is initialized.

Earliest usage of gdbarch in the callstack chain is found at create_breakpoint (breakpoint.c) as the part of its parameter. The parameter itself is originated from the call to get_current_arch function. At the end of frame_unwind_arch function, the gdbarch is initialized with next_frame->prev_arch.arch value:

sv38

The next_frame parameter is obtained from selected_frame->next static structure. Let’s create the access paths from this static structure to the above gdbarch value:

sv39

For preparation of tracking of the origin of gdbarch, this is the low level view of selected_frame to locate the ->next variable:

sv40

And the low level view of selected_frame->next for tracking the origin of prev_arch value to obtain the arch value of interest:

sv41

Don’t forget to provide address location of selected_frame structure:

sv42

Now we are ready to perform the tracking process using WinDBG:

sv43

From address info given by WinDBG we have:

sv44

The selected_frame value is initialized using call stack sequence below:

sv45

Close examination of this location revealed that the frame is returned from get_current_frame function and the value is assigned from current_frame variable:

sv46

The above method for tracking memory write is repeated and we have:

sv47

The current_frame structure is actually retrieved from eax value returned from function 0x0059d2dc which is actually:

sv48

By examining the call stack leading to this call:

sv49

The origin of current_frame structure is actually a function argument with 0x2ccdfc0 as its address and close examination of this structure revealed that gdbarch is still not initialized and its next variable is still points to itself:

sv50

To find when the arch (gdbarch) is initialized, it is necessary to locate low level address of this_frame parameter passed to get_prev_frame function:

sv51

At WinDBG session, at last we have:

sv52

The eax register value contains returned architecture (gdbarch) value. The above address is actually part of frame_unwind_arch function:

sv53

The above eax register is a call to sentinel_frame_prev_arch function which in turn calls to get_regcache_arch function and we have the partial holy grail of the origin of gdbarch as follow:

sv54

Let’s examine gdbarch properties at this stage:

sv55

To find how regcache is initialized, it is necessary to examine the creation of sentinel_frame structure, which is initialized inside get_current_frame (frame.c) function. This function accepts one of interesting parameter called regcache structure, which the structure we sought for to find the gdbarch structure. And this function is called using get_current_regcache (regcache.c) to retrieve current regcache structure.

After performing more detailed tracing of these calls, it is revealed that the gdbarch is assigned from static structure called current_thread_arch. Close examination of this structure revealed it contains arm_breakpoint that’s not recognized by my version of Android Emulator.

So, the routine of memory write tracking is again repeated, this time against initialization of current_thread_arch structure:

sv56

This time, we have:

sv57

Which is:

sv58

The call to 0x7e127c is actually a call to target dependent to retrieve the current architecture and the current_thread_arch is assigned from current_inferior_->gdbarch.

Where current_inferior_ is value is initialized at:

sv59

Which is:

sv60

This is the low level view of current_inferior_ structure at get_regcache_arch call:

sv61

The above structure will be used to find when the gdbarch is assigned at the time after the call to the above initialize_inferiors function:

sv62

Now that gdbarch initialization is found, the next step is to find arm_breakpoint assignment inside tdep structure. To achieve this, it is necessary to identify low level of tdep structure:

sv63

The function just before the arm_breakpoint initialization occurs is located inside arm_gdbarch_init:

sv64

Initialization itself is located at:

sv65

Call stack leading to the above initialization:

sv66

The initialization is using the arm_linux_arm_le_breakpoint because:

sv67

This assignment is dependent on tdep->arm_abi which is assigned to ARM_ABI_AUTO instead of ARM_ABI_AAPCS which contains working arm_breakpoint:

sv68

Based on these facts, it is possible to change the arm_breakpoint value to the working one, provided that I have to set the arm_abi assignment from ARM_ABI_AUTO to ARM_ABI_AAPCS. The arm_abi inside arm_gdbarch_init is first assigned to static variable called arm_abi_global. So, does the gdb client will deliver the working arm_breakpoint when I revise this static variable to ARM_ABI_AAPCS ?

To prove this, let’s perform setting the arm abi option to AAPCS (case sensitive) in the gdb debugger client, but you have to set it prior to any subsequent debugging command as follow:

sv69

So far so good πŸ™‚ But there are still some SIGILL crops up. Perhaps, it is caused by thumb arm breakpoint for arm thumb mode, another bugs or another unknown options to be set from gdb client.

In this case, I will leave to you, the reader of this article to solve the problem. I believe you can do it πŸ™‚

You may ask why creates such a long story if in the end, the solution is just a simple setting some option in the debugger ? It is because I do not find any working solution to this issue after some research in the net. They only offer some vague solutions that do not provide the root cause of this issue.

The only options that I have is to trace the causal chain using available building blocks that is also has to be created one by one, such as performing the compilation of gdb server and client sources.

I think the Android platform investor, decision maker and executives should consider to provide a serious, reliable and proven support ecosystem just like the one provided by Microsoft.

Without it, this platform will lack the required condition to ignite the chain reaction for an exploding ecosystem, just like a failed star such as Jupiter against the Sun πŸ™‚

Experiences in Testing Android’s gdb Client

May 30, 2015

This article, which is a sequel from previous one, will describe post compilation testing, and how to resolve issues found during testing session.

After activating the gdbserver in the emulator, I’ve found a rather cryptic error (Malformed packet(b) (missing colon)) from gdb client as follow:

tst01

Cryptic or not, the fact is the compiled gdb client failed miserably on very first attempt. Seems that the server is of higher version than the client, as evident from the version query as follow:

tst02

In my D:\Projects\Android\toolchain\gdb toolchain, there’s a newer version called gdb-7.7, so let’s try to compile this version instead. Since compiling the gdb using NDK is a rather tedious and time consuming, why not perform direct compilation in the toolchain directory as follow:

tst03

Without any incidence, the makefile is created in D:\Projects\Android\toolchain\gdb\gdb-7.7. So, let’s execute make:

tst04

So, it fails at configuring stage and complains that expat is missing. Let’s perform compilation of expat lib as follow:

tst05

After configure is finished, run the make program, and libexpat.a will be found in the .libs directory. But the above problem still exist. By checking into the config.log file inside D:\Projects\Android\toolchain\gdb\gdb-7.7\gdb:

tst06

Based on failed program info provided by config.log, let’s creates the c file and re-run the compiler. This time, let’s also activates procmon.exe to provide info of where the compiler try to search the header file:

tst07

So, let’s copy the header files from expat toolchain to c:\mingw\include and recompile. We have:

tst08

Again, based on procmon.exe info, it tries to find libexpat.a, so let’s copy the compiled libexpat.a from toolchain to c:\mingw\lib. This time, the compile is a success. Let’s run the make program again:

tst09

Copy the compiled libbfd.lib to the bfd directory and rename it to libbfd.a, we have:

tst10

After this, there are no more incidents, and gdb.exe is now exist. At my machine, it is rather large, about 30 MB:

tst11

Now, let’s test for symbol file feature, which is crucial in a debugging session:

tst12

This stops by showing Reading symbols from hello…I’m sorry, Dave, I can’t do that error message. Seems there are some flaws at compiling phase, so let’s consult the config.log file for presence of flaw:

tst13

This is a similar issue with libexpat, so let’s repeat the above procedure for libbfd library and repeat configure and make. For repeat to be a success, delete first the config.cache and makefile file, also generated *.o and *.exe inside gdb directory. Since if those files exist, it will use cache, instead of newer one. After compilation is finished, let’s try again the symbol feature:

tst14

At last, this program is ready for some real world usage πŸ™‚