我正在尝试使用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上使用基本的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
答案 0 :(得分:2)
我下载了ASOP源代码并为x86_64构建了它。在一个文件夹中,我可以找到public class YourClass ... {
public YourClass() {
throw new Exception("Ha (1)!");
InitializeComponent();
throw new Exception("Ha (2)!");
}
}
二进制文件,这就是我想要的。但我有一个问题。
首先安装所有Android库,我将dalvikvm
中的所有内容复制到out/host/linux-x86/lib/
并在/usr/bin
内翻到out/host/linux-x86/lib64/
并运行/usr/bin/x86_64-linux-gnu/
和{{1获取所有Android库(64和x86)
执行ldconfig -v -n /usr/lib
时,我得到了
ldconfig -v -n /usr/lib/x86_64-linux-gnu/
运行./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
替换为AOSP文件夹的路径。然后运行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
创建文件夹。
Dalvik正在使用32位但不是64位。这是一台运行基本OS freya的64位计算机