【问题标题】:how to add a variable in Array class in Android5.1Android5.1如何在Array类中添加变量
【发布时间】:2016-09-04 08:34:46
【问题描述】:

我正在做一些基于 Android5.1 的艺术工作,我想在 Array.h(art/runtime/mirror/Array.h) 的 Array 类中添加一个变量。

但是当我在类中添加“uint32_t 标签”时,模拟器中的系统无法启动。那么如何在Android5.1的Array.h中添加一些变量呢?

崩溃日志是这样的:

I/art     (   68): Pruning dalvik-cache since we are relocating an image and will need to recompile
I/art     (   68): RelocateImage: /system/bin/patchoat --input-image-location=/system/framework/boot.art --output-image-file=/data/dalvik-cache/arm/system@framework@boot.art --input-oat-location=/system/framework/boot.oat --output-oat-file=/data/dalvik-cache/arm/system@framework@boot.oat --instruction-set=arm --base-offset-delta=4898816
F/art     (   68): art/runtime/well_known_classes.cc:136] Couldn't find method "nativeLoad" with signature "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String;"
F/art     (   68): art/runtime/runtime.cc:289] Runtime aborting...
F/art     (   68): art/runtime/runtime.cc:289] Aborting thread:
F/art     (   68): art/runtime/runtime.cc:289] "main" prio=5 tid=1 Native (still starting up)
F/art     (   68): art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x0 self=0xb4827800
F/art     (   68): art/runtime/runtime.cc:289]   | sysTid=68 nice=0 cgrp=default sched=0/0 handle=0xb6f75bec
F/art     (   68): art/runtime/runtime.cc:289]   | state=R schedstat=( 4510000000 20420000000 715 ) utm=337 stm=114 core=0 HZ=100
F/art     (   68): art/runtime/runtime.cc:289]   | stack=0xbe500000-0xbe502000 stackSize=8MB
F/art     (   68): art/runtime/runtime.cc:289]   | held mutexes= "abort lock" "mutator lock"(shared held)
F/art     (   68): art/runtime/runtime.cc:289]   native: #00 pc 00004ef0  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art     (   68): art/runtime/runtime.cc:289]   native: #01 pc 000036d5  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art     (   68): art/runtime/runtime.cc:289]   native: #02 pc 002458fd  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
F/art     (   68): art/runtime/runtime.cc:289]   native: #03 pc 0022a051  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+144)
F/art     (   68): art/runtime/runtime.cc:289]   native: #04 pc 0021a44f  /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*)+22)
F/art     (   68): art/runtime/runtime.cc:289]   native: #05 pc 0021a6b5  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+364)
F/art     (   68): art/runtime/runtime.cc:289]   native: #06 pc 0021a881  /system/lib/libart.so (art::Runtime::Abort()+72)
F/art     (   68): art/runtime/runtime.cc:289]   native: #07 pc 000a7c57  /system/lib/libart.so (art::LogMessage::~LogMessage()+1066)
F/art     (   68): art/runtime/runtime.cc:289]   native: #08 pc 0025f515  /system/lib/libart.so (art::WellKnownClasses::LateInit(_JNIEnv*)+148)
F/art     (   68): art/runtime/runtime.cc:289]   native: #09 pc 0021a0ab  /system/lib/libart.so (art::Runtime::InitNativeMethods()+654)
F/art     (   68): art/runtime/runtime.cc:289]   native: #10 pc 0021af8b  /system/lib/libart.so (art::Runtime::Start()+670)
F/art     (   68): art/runtime/runtime.cc:289]   native: #11 pc 001d6577  /system/lib/libart.so (JNI_CreateJavaVM+526)
F/art     (   68): art/runtime/runtime.cc:289]   native: #12 pc 000604df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startVm(_JavaVM**, _JNIEnv**)+2286)
F/art     (   68): art/runtime/runtime.cc:289]   native: #13 pc 00060b27  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&)+258)
F/art     (   68): art/runtime/runtime.cc:289]   native: #14 pc 00001675  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   native: #15 pc 00012dc9  /system/lib/libc.so (__libc_init+44)
F/art     (   68): art/runtime/runtime.cc:289]   native: #16 pc 000017b0  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   (no managed stack frames)
F/art     (   68): art/runtime/runtime.cc:289] Pending exception java.lang.ExceptionInInitializerError thrown by 'unknown throw location'
F/art     (   68): art/runtime/runtime.cc:289] java.lang.ExceptionInInitializerError: 
F/art     (   68): art/runtime/runtime.cc:289]   at java.lang.String[] java.lang.Runtime.initLibPaths() (Runtime.java:73)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<init>() (Runtime.java:70)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<clinit>() (Runtime.java:65)
F/art     (   68): art/runtime/runtime.cc:289] Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=1
F/art     (   68): art/runtime/runtime.cc:289]   at java.lang.Object java.util.Hashtable.put(java.lang.Object, java.lang.Object) (Hashtable.java:384)
F/art     (   68): art/runtime/runtime.cc:289]   at java.util.Properties java.lang.System.initUnchangeableSystemProperties() (System.java:714)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.System.<clinit>() (System.java:108)
F/art     (   68): art/runtime/runtime.cc:289]   at java.lang.String[] java.lang.Runtime.initLibPaths() (Runtime.java:73)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<init>() (Runtime.java:70)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<clinit>() (Runtime.java:65)
F/art     (   68): art/runtime/runtime.cc:289] Dumping all threads without appropriate locks held: thread list lock mutator lock
F/art     (   68): art/runtime/runtime.cc:289] All threads:
F/art     (   68): art/runtime/runtime.cc:289] DALVIK THREADS (1):
F/art     (   68): art/runtime/runtime.cc:289] "main" prio=5 tid=1 Native (still starting up)
F/art     (   68): art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x0 self=0xb4827800
F/art     (   68): art/runtime/runtime.cc:289]   | sysTid=68 nice=0 cgrp=default sched=0/0 handle=0xb6f75bec
F/art     (   68): art/runtime/runtime.cc:289]   | state=R schedstat=( 4610000000 20610000000 739 ) utm=344 stm=117 core=0 HZ=100
F/art     (   68): art/runtime/runtime.cc:289]   | stack=0xbe500000-0xbe502000 stackSize=8MB
F/art     (   68): art/runtime/runtime.cc:289]   | held mutexes= "abort lock"
F/art     (   68): art/runtime/runtime.cc:289]   native: #00 pc 00004ef0  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art     (   68): art/runtime/runtime.cc:289]   native: #01 pc 000036d5  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art     (   68): art/runtime/runtime.cc:289]   native: #02 pc 002458fd  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
F/art     (   68): art/runtime/runtime.cc:289]   native: #03 pc 0022a051  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+144)
F/art     (   68): art/runtime/runtime.cc:289]   native: #04 pc 00232f85  /system/lib/libart.so (art::ThreadList::DumpLocked(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+104)
F/art     (   68): art/runtime/runtime.cc:289]   native: #05 pc 0021a635  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+236)
F/art     (   68): art/runtime/runtime.cc:289]   native: #06 pc 0021a881  /system/lib/libart.so (art::Runtime::Abort()+72)
F/art     (   68): art/runtime/runtime.cc:289]   native: #07 pc 000a7c57  /system/lib/libart.so (art::LogMessage::~LogMessage()+1066)
F/art     (   68): art/runtime/runtime.cc:289]   native: #08 pc 0025f515  /system/lib/libart.so (art::WellKnownClasses::LateInit(_JNIEnv*)+148)
F/art     (   68): art/runtime/runtime.cc:289]   native: #09 pc 0021a0ab  /system/lib/libart.so (art::Runtime::InitNativeMethods()+654)
F/art     (   68): art/runtime/runtime.cc:289]   native: #10 pc 0021af8b  /system/lib/libart.so (art::Runtime::Start()+670)
F/art     (   68): art/runtime/runtime.cc:289]   native: #11 pc 001d6577  /system/lib/libart.so (JNI_CreateJavaVM+526)
F/art     (   68): art/runtime/runtime.cc:289]   native: #12 pc 000604df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startVm(_JavaVM**, _JNIEnv**)+2286)
F/art     (   68): art/runtime/runtime.cc:289]   native: #13 pc 00060b27  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&)+258)
F/art     (   68): art/runtime/runtime.cc:289]   native: #14 pc 00001675  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   native: #15 pc 00012dc9  /system/lib/libc.so (__libc_init+44)
F/art     (   68): art/runtime/runtime.cc:289]   native: #16 pc 000017b0  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   (no managed stack frames)
F/art     (   68): art/runtime/runtime.cc:289] 
F/art     (   68): art/runtime/runtime.cc:289] 
--------- beginning of crash
F/libc    (   68): Fatal signal 6 (SIGABRT), code -6 in tid 68 (main)
I/DEBUG   (   62): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (   62): Build fingerprint: '***'
I/DEBUG   (   62): Revision: '0'
I/DEBUG   (   62): ABI: 'arm'
I/DEBUG   (   62): pid: 68, tid: 68, name: main  >>> zygote <<<
I/DEBUG   (   62): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG   (   62): Abort message: 'art/runtime/well_known_classes.cc:136] Couldn't find method "nativeLoad" with signature "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String;"'
I/DEBUG   (   62):     r0 00000000  r1 00000044  r2 00000006  r3 00000000
I/DEBUG   (   62):     r4 b6f75e38  r5 00000006  r6 00000002  r7 0000010c
I/DEBUG   (   62):     r8 00000082  r9 b486f550  sl b4827800  fp b486d480
I/DEBUG   (   62):     ip 00000044  sp becfd5f0  lr b6df3745  pc b6e176f0  cpsr 60000010
I/DEBUG   (   62): 
I/DEBUG   (   62): backtrace:
I/DEBUG   (   62):     #00 pc 0003a6f0  /system/lib/libc.so (tgkill+12)
I/DEBUG   (   62):     #01 pc 00016741  /system/lib/libc.so (pthread_kill+52)
I/DEBUG   (   62):     #02 pc 0001735f  /system/lib/libc.so (raise+10)
I/DEBUG   (   62):     #03 pc 00013b39  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   (   62):     #04 pc 00012f18  /system/lib/libc.so (abort+4)
I/DEBUG   (   62):     #05 pc 0021a8d9  /system/lib/libart.so (art::Runtime::Abort()+160)
I/DEBUG   (   62):     #06 pc 000a7c57  /system/lib/libart.so (art::LogMessage::~LogMessage()+1066)
I/DEBUG   (   62):     #07 pc 0025f515  /system/lib/libart.so (art::WellKnownClasses::LateInit(_JNIEnv*)+148)
I/DEBUG   (   62):     #08 pc 0021a0ab  /system/lib/libart.so (art::Runtime::InitNativeMethods()+654)
I/DEBUG   (   62):     #09 pc 0021af8b  /system/lib/libart.so (art::Runtime::Start()+670)
I/DEBUG   (   62):     #10 pc 001d6577  /system/lib/libart.so (JNI_CreateJavaVM+526)
I/DEBUG   (   62):     #11 pc 000604df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startVm(_JavaVM**, _JNIEnv**)+2286)
I/DEBUG   (   62):     #12 pc 00060b27  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&)+258)
I/DEBUG   (   62):     #13 pc 00001675  /system/bin/app_process32
I/DEBUG   (   62):     #14 pc 00012dc9  /system/lib/libc.so (__libc_init+44)
I/DEBUG   (   62):     #15 pc 000017b0  /system/bin/app_process32
I/DEBUG   (   62): 
I/DEBUG   (   62): Tombstone written to: /data/tombstones/tombstone_00

【问题讨论】:

  • 适用于 Android 的 C++?我记得是Java
  • @FirstStep Android 源代码 (AOSP) 中的“Array.h”
  • 您不能只编辑 Android 的源代码,正如您所发现的那样。目标设备上不会有您的更改,因为显然您不能仅通过安装您的应用程序来重写操作系统。你想完成什么?
  • @nasch 我可以编译源代码并构建一个模拟器来运行已更改的系统。我想更改可以将标签放入其中的 Array.h,因此 Java 中的每个数组都会有这个标签。
  • 我可以看到,但目标是什么?我认为你想要这样做有一些潜在的原因。你唯一的计划是在模拟器上运行它,你不需要分发给任何人?我对更改 android 系统一无所知,所以如果这确实是您需要做的,我无法帮助您。但这听起来像是面向方面编程可以做的事情。

标签: android c++ operating-system android-source art-runtime


【解决方案1】:

赵开元,

首先,我不确定你为什么希望每个数组都有你的标签,但问题不是真的为什么,而是如何。

方法如下:您需要在 .h 文件中对其进行更改,然后浏览整个 android 源代码并更改对数组元素的每次调用以将您的更改考虑在内。这是一项乏味且在我看来不值得的任务。无论如何,这就是HOW。最后编写一个脚本来为您解决这个问题可能会更容易。

如果你还想做这样的事情,我祝你好运并快速解决。另外,如果您确实想出了某种脚本,我会很想看到它。在其他情况下,它也是一个有用的脚本。

【讨论】:

    猜你喜欢
    • 2019-03-29
    • 1970-01-01
    • 2020-12-03
    • 2020-02-05
    • 2017-09-11
    • 2018-10-05
    • 2022-10-25
    • 2019-01-27
    • 2023-03-21
    相关资源
    最近更新 更多