Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从源代码编译Android运行时(ART)_Java_Android_Git_Android Ndk - Fatal编程技术网

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

Java 如何从源代码编译Android运行时(ART),java,android,git,android-ndk,Java,Android,Git,Android Ndk,我正在尝试使用Android NDK编译Android运行时。首先,我克隆了存储库并切换到棉花糖cts发行版分支。然后在运行ndk build时 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

我正在尝试使用Android NDK编译Android运行时。首先,我克隆了存储库并切换到
棉花糖cts发行版
分支。然后在运行
ndk build

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)
suici@HP-展馆-g7:~/art$ndk建造
Android NDK:找不到应用程序项目目录!
Android NDK:请定义NDK_PROJECT_PATH变量以指向它。
/usr/local/src/android-sdk-linux_x86/ndk bundle/build/core/build local.mk:151:**android-ndk:中止。停止
suici@HP-g7展馆:~/艺术美元
我如何编译这个?我需要整个Android源代码树吗?还是我做错了什么

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

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

git克隆https://android.googlesource.com/platform/art
cd艺术
git checkout棉花糖cts发布
导出NDK_项目路径=$PWD
ndk build APP_build_SCRIPT=Android.mk
我明白了

echo$NDK\u项目路径的输出

/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\u 64-linux-gnu/
中,然后运行
ldconfig-v-n/usr/lib
ldconfig-v-n/usr/lib/x86\u 64-linux-gnu/
,以获取所有信息Android LIB(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)
更换
!!!路径到AOSP指向AOSP文件夹的路径。然后运行
mkdir-p$ANDROID_DATA/dalvik cache
创建文件夹


Dalvik使用的是32位,而不是64位。这是一台运行初级操作系统freya的64位计算机

echo NDK_项目路径
ls~/art
@m0skit0的结果发布到answer@m0skit0我已经解决了这个问题,但它需要作为32位运行,这是恼人的,可能会很慢(不知道,但我的Nexus 9 64位速度很快,因为它使用64位ART/Dalvik)
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