gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 09:47:46 25 4
gpt4 key购买 nike

我正在尝试使用 Android NDK 编译 Android 运行时。首先,我克隆了存储库并切换到 marshmallow-cts-release 分支。然后当运行 ndk-build 我得到

suici@HP-Pavilion-g7:~/art$ ndk-build
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/build-local.mk:151: *** Android NDK: Aborting . Stop.
suici@HP-Pavilion-g7:~/art$

我该如何编译它?我需要整个 Android 源代码树吗?还是我做错了什么?

存储库包含 Android.mk 文件。我在 HP Pavilion g7-2269wm 上使用 elementary OS freya 64 位(基于 Ubuntu)。安装了最新的 SDK 和 NDK。

在克隆 ART 的源代码并通过运行以下命令对其进行编译之后。

git clone https://android.googlesource.com/platform/art
cd art
git checkout marshmallow-cts-release
export NDK_PROJECT_PATH=$PWD
ndk-build APP_BUILD_SCRIPT=Android.mk

我明白了

build/Android.common_path.mk:20: art/build/Android.common.mk: No such file or directory
build/Android.oat.mk:24: art/build/Android.common_build.mk: No such file or directory
build/Android.oat.mk:143: warning: overriding commands for target `/core.art'
build/Android.oat.mk:143: warning: ignoring old commands for target `/core.art'
build/Android.oat.mk:143: warning: overriding commands for target `/core-pic.art'
build/Android.oat.mk:143: warning: ignoring old commands for target `/core-pic.art'
build/Android.oat.mk:144: warning: overriding commands for target `/core-optimizing.art'
build/Android.oat.mk:144: warning: ignoring old commands for target `/core-optimizing.art'
build/Android.oat.mk:144: warning: overriding commands for target `/core-optimizing-pic.art'
build/Android.oat.mk:144: warning: ignoring old commands for target `/core-optimizing-pic.art'
build/Android.oat.mk:145: warning: overriding commands for target `/core-interpreter.art'
build/Android.oat.mk:145: warning: ignoring old commands for target `/core-interpreter.art'
build/Android.oat.mk:145: warning: overriding commands for target `/core-interpreter-pic.art'
build/Android.oat.mk:145: warning: ignoring old commands for target `/core-interpreter-pic.art'
build/Android.oat.mk:149: warning: overriding commands for target `/corevalgrind.art'
build/Android.oat.mk:149: warning: ignoring old commands for target `/corevalgrind.art'
build/Android.oat.mk:149: warning: overriding commands for target `/core-picvalgrind.art'
build/Android.oat.mk:149: warning: ignoring old commands for target `/core-picvalgrind.art'
build/Android.oat.mk:150: warning: overriding commands for target `/core-optimizingvalgrind.art'
build/Android.oat.mk:150: warning: ignoring old commands for target `/core-optimizingvalgrind.art'
build/Android.oat.mk:150: warning: overriding commands for target `/core-optimizing-picvalgrind.art'
build/Android.oat.mk:150: warning: ignoring old commands for target `/core-optimizing-picvalgrind.art'
build/Android.oat.mk:151: warning: overriding commands for target `/core-interpretervalgrind.art'
build/Android.oat.mk:151: warning: ignoring old commands for target `/core-interpretervalgrind.art'
build/Android.oat.mk:151: warning: overriding commands for target `/core-interpreter-picvalgrind.art'
build/Android.oat.mk:151: warning: ignoring old commands for target `/core-interpreter-picvalgrind.art'
build/Android.cpplint.mk:17: art/build/Android.common_build.mk: No such file or directory
find: `art': No such file or directory
runtime/Android.mk:19: art/build/Android.common_build.mk: No such file or directory
compiler/Android.mk:19: art/build/Android.common_build.mk: No such file or directory
dex2oat/Android.mk:19: art/build/Android.executable.mk: No such file or directory
disassembler/Android.mk:19: art/build/Android.common_build.mk: No such file or directory
oatdump/Android.mk:19: art/build/Android.executable.mk: No such file or directory
imgdiag/Android.mk:19: art/build/Android.executable.mk: No such file or directory
patchoat/Android.mk:19: art/build/Android.executable.mk: No such file or directory
dalvikvm/Android.mk:19: art/build/Android.common.mk: No such file or directory
dalvikvm/Android.mk:42: /usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/executable_prefer_symlink.mk: No such file or directory
dalvikvm/Android.mk:72: /usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/build-host-executable.mk: No such file or directory
dalvikvm/Android.mk:75: /usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/executable_prefer_symlink.mk: No such file or directory
tools/Android.mk:25: /usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/base_rules.mk: No such file or directory
tools/Android.mk:35: /usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/base_rules.mk: No such file or directory
tools/dexfuzz/Android.mk:33: /usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/base_rules.mk: No such file or directory
sigchainlib/Android.mk:19: art/build/Android.common_build.mk: No such file or directory
Android NDK: Trying to define local module 'sigchain' in sigchainlib/Android.mk.
Android NDK: But this module was already defined by sigchainlib/Android.mk.
/usr/local/src/android-sdk-linux_x86/ndk-bundle/build/core/build-module.mk:34: *** Android NDK: Aborting. . Stop.

echo $NDK_PROJECT_PATH 的输出

/home/suici/AndroidRuntime/art

ls $PWD 的输出

Android.mk    cmdline   dex2oat       MODULE_LICENSE_APACHE2  patchoat     test
build compiler disassembler NOTICE runtime tools
CleanSpec.mk dalvikvm imgdiag oatdump sigchainlib

最佳答案

我下载了 ASOP 源代码并为 x86_64 构建了它。在一个文件夹中,我可以找到我想要的 dalvikvm 二进制文件。但我对此有疑问。

首先要安装所有 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)

当执行 ./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 后添加以下行,一切似乎都正常工作。

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 来创建文件夹。

Dalvik 在 32 位上工作,但在 64 位上不工作。这是一台运行 elementary OS freya 的 64 位计算机

关于java - 如何从源代码编译 Android 运行时 (ART),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37107080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com