I have compiled and ran Android 8 on emulator. I want to view the behavior of ART when installing and opening an application in AOSP. I added this line to dex2aot.cc file:
#include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native-lib", __VA_ARGS__))
#define LOG_TAG "foo"
and this one LOGI("DOOOOOOOOTOOOOOOOOOOOOOOOO");
~Dex2Oat() {
// Log completion time before deleting the runtime_, because this accesses
// the runtime.
LOGI("DOOOOOOOOTOOOOOOOOOOOOOOOO");
LogCompletionTime();
I also created android.mk in the dex2aot folder containing this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES:= liblog
Then I run these commands
source build/envsetup.sh
lunch aosp_arm-eng
make -j8
And I get undefined reference
error. I looked up the error, but most solutions are very old. Is there any new solution? Should I modify android.mk in the build folder? I appreciate your help.
Regards,
I also created android.mk in the dex2oat folder
This does not work. The pattern for declaring a module in an Android.mk would be, e.g. for creating a binary:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
...
LOCAL_MODULE := name_of_your_module
include $(BUILD_EXECUTABLE)
This defines a new module name_of_your_module
, which is of type executable. You could then fill in details about the module in place of the ...
, for example you could add source files with LOCAL_SRC_FILES := ...
or link against shared libraries with LOCAL_SHARED_LIBRARIES := ...
.
In the code you posted, you gave the LOCAL_SHARED_LIBRARIES
declaration, but I do not see a module declaration surrounding it. So the build system has no way of knowing what module wants to link against liblog
. So when you would want to declare a new module linking against liblog, you would have to make sure that your LOCAL_SHARED_LIBRARIES
is in between a include $(CLEAR_VARS)
and a LOCAL_MODULE := ...
/ include $(BUILD_EXECUTABLE)
(or an other module type, in case you want to build a static or shared library).
However, this only applies when you want to create a new module. From what I understand, you do not actually want to create a new module, but add a linker dependency to an existing module, namely dex2oat
. To achieve this, you would have to modify the existing module declaration of dex2oat
. Now you said you are using Android 8, where this module is in declared in ./art/dex2oat/Android.bp
. Creating a new Android.mk for an existing module declared in a Android.bp will not work. Instead you have to modify the Android.bp.
In ./art/dex2oat/Android.bp
, find the module declaration of dex2oat
:
art_cc_binary {
name: "dex2oat",
defaults: [
"dex2oat-defaults",
],
shared_libs: [
"libart",
"libart-compiler",
"libbase",
"libsigchain",
],
}
In the shared_libs
list, add the library you want to link against, so in your case, "liblog"
.