首页
社区
课程
招聘
未解决 [求助]Ubuntu20.04编译AOSP8.1.0_r1时报错 100雪币
发表于: 2025-8-11 17:37 357

未解决 [求助]Ubuntu20.04编译AOSP8.1.0_r1时报错 100雪币

2025-8-11 17:37
357

在使用Ubuntu编译时报以下错误,求助解答


报错太长了,截取了一段,搜了一些关于Failed to find ANDROID_DATA directory /data的解决方法,发现依旧报错(可能是我找的帖子不对)


[  0% 2/20228] Ensuring Jack server is installed and started

Jack server already installed in "/home/ddd/.jack-server"

Server is already running

[  0% 12/20228] Dexpreopt Jar: uiautomator (out/target/product/sailfish/obj/JAVA_LIBRARIES/uiautomator_intermediates/oat/arm64/javalib.odex)

FAILED: out/target/product/sailfish/obj/JAVA_LIBRARIES/uiautomator_intermediates/oat/arm64/javalib.odex 

/bin/bash -c "(rm -f out/target/product/sailfish/obj/JAVA_LIBRARIES/uiautomator_intermediates/oat/arm64/javalib.odex ) && (mkdir -p out/target/product/sailfish/obj/JAVA_LIBRARIES/uiautomator_intermediates/oat/arm64/ ) && (ANDROID_LOG_TAGS=\"*:e\" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx512m --class-loader-context=\"&\" --boot-image=out/target/product/sailfish/dex_bootjars/system/framework/boot.art --dex-file=out/target/common/obj/JAVA_LIBRARIES/uiautomator_intermediates/javalib.jar --dex-location=/system/framework/uiautomator.jar --oat-file=out/target/product/sailfish/obj/JAVA_LIBRARIES/uiautomator_intermediates/oat/arm64/javalib.odex --android-root=out/target/product/sailfish/system --instruction-set=arm64 --instruction-set-variant=kryo --instruction-set-features=default --runtime-arg -Xnorelocate --compile-pic --no-generate-debug-info --generate-build-id --abort-on-hard-verifier-error --force-determinism --no-inline-from=core-oj.jar  --compiler-filter=quicken )"

dex2oatd F 08-11 16:43:43 335411 335411 utils.cc:762] Failed to find ANDROID_DATA directory /data

Runtime aborting...

Dumping all threads without appropriate locks held: thread list lock mutator lock

All threads:

DALVIK THREADS (0):

"dex2oatd" prio=5 (not attached)

  | sysTid=335411 nice=0 cgrp=default

  | state=R schedstat=( 17271785 20108787 7 ) utm=1 stm=0 core=6 HZ=100

  native: #00 pc 00000000004f5619  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)+217)

  native:   art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)

  native:    art/runtime/native_stack_dump.cc:300

  native: #01 pc 00000000005edab0  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::ThreadList::DumpUnattachedThreads(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+352)

  native:   art::DumpUnattachedThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, bool)

  native:    art/runtime/thread_list.cc:166

  native:   art::ThreadList::DumpUnattachedThreads(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool)

  native:    art/runtime/thread_list.cc:189

  native: #02 pc 00000000005ed880  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+288)

  native:   art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool)

  native:    art/runtime/thread_list.cc:267

  native: #03 pc 00000000005c425b  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&) const+299)

  native: #04 pc 00000000005b5194  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::Runtime::Abort(char const*)+100)

  native: #05 pc 000000000000976a  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libbase.so (android::base::LogMessage::~LogMessage()+858)

  native:   std::__1::function<void (char const*)>::operator()(char const*) const

  native:    external/libcxx/include/functional:1915

  native:   android::base::LogMessage::~LogMessage()

  native:    system/core/base/logging.cpp:433

  native: #06 pc 0000000000609049  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::GetAndroidDir(char const*, char const*)+233)

  native:   art::GetAndroidDir(char const*, char const*)

  native:    art/runtime/utils.cc:762

  native: #07 pc 00000000006094af  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::GetDalvikCache(char const*)+63)

  native:   art::GetAndroidData()

  native:    art/runtime/utils.cc:776

  native:   art::GetDalvikCache(char const*)

  native:    art/runtime/utils.cc:817

  native: #08 pc 000000000034efb3  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::space::PruneDalvikCache(art::InstructionSet)+67)

  native: #09 pc 000000000034cf0f  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::space::ImageSpace::CreateBootImage(char const*, art::InstructionSet, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*)+3935)

  native:   art::gc::space::PruneDalvikCache(art::InstructionSet)

  native:    art/runtime/gc/space/image_space_fs.h:95

  native:   art::gc::space::ImageSpace::CreateBootImage(char const*, art::InstructionSet, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)

  native:    art/runtime/gc/space/image_space.cc:1630

  native: #10 pc 000000000034f3be  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::space::ImageSpace::LoadBootImage(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, art::InstructionSet, std::__1::vector<art::gc::space::ImageSpace*, std::__1::allocator<art::gc::space::ImageSpace*>>*, unsigned char**)+622)

  native:   art::gc::space::ImageSpace::LoadBootImage(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, art::InstructionSet, std::__1::vector<art::gc::space::ImageSpace*, std::__1::allocator<art::gc::space::ImageSpace*> >*, unsigned char**)

  native:    art/runtime/gc/space/image_space.cc:1668

  native: #11 pc 0000000000316e8b  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::Heap::Heap(unsigned long, unsigned long, unsigned long, unsigned long, double, double, unsigned long, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, art::InstructionSet, art::gc::CollectorType, art::gc::CollectorType, art::gc::space::LargeObjectSpaceType, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned long, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, unsigned long)+1851)

  native: #12 pc 00000000005b7c0c  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (_ZN3art7Runtime4InitEONS_18RuntimeArgumentMapE+9500)

  native: #13 pc 00000000005b569a  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (_ZN3art7Runtime6CreateEONS_18RuntimeArgumentMapE+74)

  native: #14 pc 000000000001d711  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (_ZN3art7Dex2Oat13CreateRuntimeEONS_18RuntimeArgumentMapE+65)

  native: #15 pc 0000000000011e71  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (art::Dex2Oat::Setup()+2977)

  native: #16 pc 000000000000be74  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (main+756)

  native: #17 pc 0000000000001d8f  /usr/lib/x86_64-linux-gnu/libc.so.6 (???)

  native: #18 pc 0000000000001e3f  /usr/lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+127)

  native:   ??

  native:    ??:0

  native: #19 pc 000000000000ba58  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (???)


"dex2oat watch d" prio=5 (not attached)

  | sysTid=335412 nice=0 cgrp=default

  | state=S schedstat=( 18745 3138500 1 ) utm=0 stm=0 core=3 HZ=100

  kernel: (couldn't read /proc/self/task/335412/stack)

  native: #00 pc 0000000000069117  /usr/lib/x86_64-linux-gnu/libc.so.6 (???)

  native: #01 pc 000000000006be9a  /usr/lib/x86_64-linux-gnu/libc.so.6 (pthread_cond_timedwait+570)

  native:   __vfwscanf_internal

  native:    ./stdio-common/vfscanf-internal.c:1733

  native: #02 pc 000000000001612d  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (art::WatchDog::Wait()+109)

  native: #03 pc 00000000000160ac  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (art::WatchDog::CallBack(void*)+28)

  native: #04 pc 000000000006cac2  /usr/lib/x86_64-linux-gnu/libc.so.6 (???)

  native: #05 pc 00000000000fe84f  /usr/lib/x86_64-linux-gnu/libc.so.6 (???)

  native: #06 pc 0000000000000000  ???


(Aborting thread was not attached to runtime!)

  native: #00 pc 00000000004f5619  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)+217)

  native:   art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)

  native:    art/runtime/native_stack_dump.cc:300

  native: #01 pc 00000000005b5194  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::Runtime::Abort(char const*)+100)

  native: #02 pc 000000000000976a  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libbase.so (android::base::LogMessage::~LogMessage()+858)

  native:   std::__1::function<void (char const*)>::operator()(char const*) const

  native:    external/libcxx/include/functional:1915

  native:   android::base::LogMessage::~LogMessage()

  native:    system/core/base/logging.cpp:433

  native: #03 pc 0000000000609049  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::GetAndroidDir(char const*, char const*)+233)

  native:   art::GetAndroidDir(char const*, char const*)

  native:    art/runtime/utils.cc:762

  native: #04 pc 00000000006094af  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::GetDalvikCache(char const*)+63)

  native:   art::GetAndroidData()

  native:    art/runtime/utils.cc:776

  native:   art::GetDalvikCache(char const*)

  native:    art/runtime/utils.cc:817

  native: #05 pc 000000000034efb3  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::space::PruneDalvikCache(art::InstructionSet)+67)

  native: #06 pc 000000000034cf0f  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::space::ImageSpace::CreateBootImage(char const*, art::InstructionSet, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*)+3935)

  native:   art::gc::space::PruneDalvikCache(art::InstructionSet)

  native:    art/runtime/gc/space/image_space_fs.h:95

  native:   art::gc::space::ImageSpace::CreateBootImage(char const*, art::InstructionSet, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)

  native:    art/runtime/gc/space/image_space.cc:1630

  native: #07 pc 000000000034f3be  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::space::ImageSpace::LoadBootImage(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, art::InstructionSet, std::__1::vector<art::gc::space::ImageSpace*, std::__1::allocator<art::gc::space::ImageSpace*>>*, unsigned char**)+622)

  native:   art::gc::space::ImageSpace::LoadBootImage(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, art::InstructionSet, std::__1::vector<art::gc::space::ImageSpace*, std::__1::allocator<art::gc::space::ImageSpace*> >*, unsigned char**)

  native:    art/runtime/gc/space/image_space.cc:1668

  native: #08 pc 0000000000316e8b  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (art::gc::Heap::Heap(unsigned long, unsigned long, unsigned long, unsigned long, double, double, unsigned long, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, art::InstructionSet, art::gc::CollectorType, art::gc::CollectorType, art::gc::space::LargeObjectSpaceType, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned long, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, unsigned long)+1851)

  native: #09 pc 00000000005b7c0c  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (_ZN3art7Runtime4InitEONS_18RuntimeArgumentMapE+9500)

  native: #10 pc 00000000005b569a  /home/ddd/aosp810r1/out/host/linux-x86/lib64/libartd.so (_ZN3art7Runtime6CreateEONS_18RuntimeArgumentMapE+74)

  native: #11 pc 000000000001d711  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (_ZN3art7Dex2Oat13CreateRuntimeEONS_18RuntimeArgumentMapE+65)

  native: #12 pc 0000000000011e71  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (art::Dex2Oat::Setup()+2977)

  native: #13 pc 000000000000be74  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (main+756)

  native: #14 pc 0000000000001d8f  /usr/lib/x86_64-linux-gnu/libc.so.6 (???)

  native: #15 pc 0000000000001e3f  /usr/lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+127)

  native:   ??

  native:    ??:0

  native: #16 pc 000000000000ba58  /home/ddd/aosp810r1/out/host/linux-x86/bin/dex2oatd (???)

/bin/bash: line 1: 335465 Aborted                 (core dumped) ( ANDROID_LOG_TAGS="*:e" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx512m --class-loader-context="&" --boot-image=out/target/product/sailfish/dex_bootjars/system/framework/boot.art --dex-file=out/target/common/obj/JAVA_LIBRARIES/bmgrlib_intermediates/javalib.jar --dex-location=/system/framework/bmgr.jar --oat-file=out/target/product/sailfish/obj/JAVA_LIBRARIES/bmgrlib_intermediates/oat/arm/javalib.odex --android-root=out/target/product/sailfish/system --instruction-set=arm --instruction-set-variant=kryo --instruction-set-features=default --runtime-arg -Xnorelocate --compile-pic --no-generate-debug-info --generate-build-id --abort-on-hard-verifier-error --force-determinism --no-inline-from=core-oj.jar --compiler-filter=quicken )

[  0% 18/20228] Dexpreopt Jar: inputlib (out/target/product/sailfish/obj/JAVA_LIBRARIES/inputlib_intermediates/oat/arm64/javalib.odex)

FAILED: out/target/product/sailfish/obj/JAVA_LIBRARIES/inputlib_intermediates/oat/arm64/javalib.odex 

/bin/bash -c "(rm -f out/target/product/sailfish/obj/JAVA_LIBRARIES/inputlib_intermediates/oat/arm64/javalib.odex ) && (mkdir -p out/target/product/sailfish/obj/JAVA_LIBRARIES/inputlib_intermediates/oat/arm64/ ) && (ANDROID_LOG_TAGS=\"*:e\" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx512m --class-loader-context=\"&\" --boot-image=out/target/product/sailfish/dex_bootjars/system/framework/boot.art --dex-file=out/target/common/obj/JAVA_LIBRARIES/inputlib_intermediates/javalib.jar --dex-location=/system/framework/input.jar --oat-file=out/target/product/sailfish/obj/JAVA_LIBRARIES/inputlib_intermediates/oat/arm64/javalib.odex --android-root=out/target/product/sailfish/system --instruction-set=arm64 --instruction-set-variant=kryo --instruction-set-features=default --runtime-arg -Xnorelocate --compile-pic --no-generate-debug-info --generate-build-id --abort-on-hard-verifier-error --force-determinism --no-inline-from=core-oj.jar  --compiler-filter=quicken )"

dex2oatd F 08-11 16:43:44 335492 335492 utils.cc:762] Failed to find ANDROID_DATA directory /data



传播安全知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 45510
活跃值: (67836)
能力值: (RANK:145 )
在线值:
发帖
回帖
粉丝
2

问下chatgpt或deepseek等AI:

这个错误是由于编译过程中 dex2oatd 工具无法找到 /data 目录导致的。在 Android 编译环境中,dex2oat (或 dex2oatd 调试版本) 需要访问 /data 目录来创建和缓存编译后的 ART 文件。

解决方案:

1. 创建并设置 ANDROID_DATA 环境变量

dex2oatd 需要 ANDROID_DATA 环境变量指向一个有效的目录(通常是 /data)。在 Ubuntu 上编译时,可以手动设置这个变量:

bash

export ANDROID_DATA=/tmp/android-datamkdir -p $ANDROID_DATA/dalvik-cache

然后重新运行编译命令。

2. 确保编译环境正确初始化

在编译 Android 源代码之前,确保已正确运行以下命令:

bash

source build/envsetup.sh
lunch sailfish-userdebug  # 根据你的目标设备选择正确的 lunch 选项

3. 检查文件系统权限

确保 /tmp 或你设置的 ANDROID_DATA 目录有正确的读写权限:

bash

chmod -R 777 /tmp/android-data

4. 完整清理并重新编译

如果问题仍然存在,尝试完全清理并重新编译:

bash

make cleanrm -rf out/source build/envsetup.sh
lunch sailfish-userdebugmake -j$(nproc)

5. 检查 SELinux 限制

如果系统启用了 SELinux,可能需要临时禁用:

bash

setenforce 0

6. 使用 Docker 或官方支持的编译环境

如果问题仍然无法解决,建议使用 Google 官方推荐的 Docker 编译环境或 Ubuntu 版本,确保环境一致性。

根本原因:

dex2oatd 是 Android Runtime (ART) 的一部分,用于将 DEX 文件编译为 OAT 文件。它默认会在 /data/dalvik-cache 中生成缓存文件。在主机上编译时,需要模拟这个环境。

如果以上方法仍不能解决,可能是你的 Android 版本(AOSP 8.1.0_r1)与当前主机环境存在兼容性问题,建议检查 AOSP 官方文档或社区中针对该版本的特定编译说明。


2025-8-11 18:08
1
雪    币: 7020
活跃值: (7177)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
建议Ubuntu配置一下jackserver端口就可以
2025-8-11 21:20
0
游客
登录 | 注册 方可回帖
返回