且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从源代码编译Android运行时(ART)

更新时间:2023-02-20 21:26:29

我下载了ASOP源并将其构建为x86_64.在一个文件夹中,我可以找到dalvikvm二进制文件.但我对此有疑问.

I downloaded the ASOP source and built it for x86_64. In a folder I could find the dalvikvm binary which is what I wanted. But I have a problem with it.

首先安装所有Android库,我将out/host/linux-x86/lib/中的所有内容复制到/usr/bin,并将out/host/linux-x86/lib64/中的所有内容复制到/usr/bin/x86_64-linux-gnu/,并运行ldconfig -v -n /usr/libldconfig -v -n /usr/lib/x86_64-linux-gnu/以获取所有Android库(64和x86) )

First to install all the Android libraries I copied everything in out/host/linux-x86/lib/ to /usr/bin and everthing in out/host/linux-x86/lib64/ to /usr/bin/x86_64-linux-gnu/ and ran ldconfig -v -n /usr/lib and ldconfig -v -n /usr/lib/x86_64-linux-gnu/ to get all the Android libs (64 and x86)

执行./dalvikvm时我得到

art F  6066  6066 art/runtime/utils.cc:1218] ANDROID_ROOT not set and /system does not exist
art F 6066 6066 art/runtime/runtime.cc:366]Runtime aborting...
(Aborting thread was not attached to runtime!)
  native: #00 pc 000000000040de55  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+213)
  native:   art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)
  native:    /mnt/storage/AOSP/art/runtime/utils.cc:1102
  native: #01 pc 00000000003cb9b4  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+292)
  native:   art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const
  native:    /mnt/storage/AOSP/art/runtime/runtime.cc:308
  native: #02 pc 00000000003bea5f  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::Runtime::Abort()+127)
  native:   art::Dumpable<art::AbortState>::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const
  native:    /mnt/storage/AOSP/art/runtime/base/dumpable.h:38
  native:   std::__1::basic_ostream<char, std::__1::char_traits<char> >& art::operator<< <art::AbortState>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Dumpable<art::AbortState> const&)
  native:    /mnt/storage/AOSP/art/runtime/base/dumpable.h:49
  native:   art::Runtime::Abort()
  native:    /mnt/storage/AOSP/art/runtime/runtime.cc:366
  native: #03 pc 000000000010ed1e  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::LogMessage::~LogMessage()+1150)
  native:   ~LogMessage
  native:    /mnt/storage/AOSP/art/runtime/base/logging.cc:226
  native: #04 pc 000000000040ec37  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::GetAndroidRoot()+231)
  native:   art::GetAndroidRoot()
  native:    /mnt/storage/AOSP/art/runtime/utils.cc:1223
  native: #05 pc 000000000036906f  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::ParsedOptions::Parse(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool, art::RuntimeArgumentMap*)+4351)
  native:   art::ParsedOptions::Parse(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool, art::RuntimeArgumentMap*)
  native:    /mnt/storage/AOSP/art/runtime/parsed_options.cc:534
  native: #06 pc 0000000000367edf  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::ParsedOptions::Create(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool, art::RuntimeArgumentMap*)+95)
  native:   art::ParsedOptions::Create(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool, art::RuntimeArgumentMap*)
  native:    /mnt/storage/AOSP/art/runtime/parsed_options.cc:49
  native: #07 pc 00000000003bf2f8  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::Runtime::Init(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool)+136)
  native:   art::Runtime::Init(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool)
  native:    /mnt/storage/AOSP/art/runtime/runtime.cc:791
  native: #08 pc 00000000003bf24b  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (art::Runtime::Create(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool)+75)
  native:   art::Runtime::Create(std::__1::vector<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void const*> > > const&, bool)
  native:    /mnt/storage/AOSP/art/runtime/runtime.cc:417
  native: #09 pc 00000000002be339  /mnt/storage/AOSP/out/host/linux-x86/lib64/libart.so (JNI_CreateJavaVM+569)
  native:   JNI_CreateJavaVM
  native:    /mnt/storage/AOSP/art/runtime/java_vm_ext.cc:805
  native: #10 pc 0000000000001e1f  /mnt/storage/AOSP/out/host/linux-x86/bin/dalvikvm64 (main+463)
  native:   art::dalvikvm(int, char**)
  native:    /mnt/storage/AOSP/art/dalvikvm/dalvikvm.cc:177
  native:   main
  native:    /mnt/storage/AOSP/art/dalvikvm/dalvikvm.cc:212
  native: #11 pc 0000000000021ec4  /lib/x86_64-linux-gnu/libc-2.19.so (__libc_start_main+244)
  native:   __libc_start_main
  native:    /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:287
  native: #12 pc 0000000000001b28  /mnt/storage/AOSP/out/host/linux-x86/bin/dalvikvm64 (???)

Aborted (core dumped)

运行dalvikvm --32时,通过添加以下几行来修改~/.bashrc后,一切似乎都能正常工作.

When running dalvikvm --32 everything seems to work correctly after modifying my ~/.bashrc by adding the following lines to it.

export ANDROID_ROOT=!!!PATH-TO-AOSP!!!/out/debug/host/linux-x86/product/generic_x86_64/system

# configure bootclasspath
export BOOTCLASSPATH=$ANDROID_ROOT/framework/core.jar:$ANDROID_ROOT/framework/ext.jar:$ANDROID_ROOT/framework/framework.jar:$ANDROID_ROOT/framework/android.policy.jar:$ANDROID_ROOT/framework/services.jar

# this is where we create the dalvik-cache directory; make sure it exists
export ANDROID_DATA=/tmp/dalvik_$USER

!!!PATH-TO-AOSP!!!替换为AOSP文件夹的路径,然后运行mkdir -p $ANDROID_DATA/dalvik-cache创建文件夹.

Replace !!!PATH-TO-AOSP!!! with the path to your AOSP folder.Then running mkdir -p $ANDROID_DATA/dalvik-cache to create the folders.

Dalvik是在32位系统上运行,而不是在64位系统上运行.这是一台运行基本操作系统freya的64位计算机

Dalvik is working in 32-bit but not in 64-bit.This is a 64-bit computer running elementary OS freya