提问人:VanessaF 提问时间:8/21/2023 更新时间:8/21/2023 访问量:64
使用自定义 png 文件在 Android 的图像视图中呈现错误
Rendering error in Android's image view by using custom made png file
问:
我有一个非常奇怪的错误,与使用自制的 png 文件的 Android 中的自定义图像视图有关。此错误可能难以调试。不过,我只是想在不使用自定义图像视图之前问你们。
所以我有以下图像视图
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="22dp" />
<solid android:color="#ffffff" />
</shape>
</item>
<item
android:drawable="@drawable/window_open_no_arrows"
android:width="45dp"
android:height="45dp"
android:gravity="left|center_vertical" />
</layer-list>
我使用以下代码从中创建一个图像视图:
final ImageView flyingButton = new ImageView(getContext());
flyingButton.setImageResource(R.drawable.flying_button_air_1);
我给它制作动画(所以它在屏幕上飞过)。实际上代码相当复杂,所以我无法向您展示。但是您需要知道的是,根据此行中指定的可拖曳对象,一切正常,或者我收到未指定的错误消息并且应用程序崩溃(此处是它的摘录):android:drawable="@drawable/window_open_no_arrows"
A GL errors! frameworks/base/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp:127
2023-08-21 10:46:59.626 22025-22051 om.example.gam com.example.game A runtime.cc:655] Runtime aborting...
runtime.cc:655] Dumping all threads without mutator lock held
runtime.cc:655] All threads:
runtime.cc:655] DALVIK THREADS (14):
runtime.cc:655] "RenderThread" prio=10 tid=18 Runnable
runtime.cc:655] | group="" sCount=0 dsCount=0 flags=0 obj=0x132c06d8 self=0xdd591810
runtime.cc:655] | sysTid=22051 nice=-10 cgrp=top-app sched=0/0 handle=0xbbdb01e0
runtime.cc:655] | state=R schedstat=( 70660625928 3318920954 65423 ) utm=455 stm=6610 core=1 HZ=100
runtime.cc:655] | stack=0xbbcb5000-0xbbcb7000 stackSize=1008KB
runtime.cc:655] | held mutexes= "abort lock" "mutator lock"(shared held)
runtime.cc:655] native: #00 pc 00542d9e /apex/com.android.art/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+110)
runtime.cc:655] native: #01 pc 006a0897 /apex/com.android.art/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const+1015)
runtime.cc:655] native: #02 pc 0069a171 /apex/com.android.art/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const+65)
runtime.cc:655] native: #03 pc 006c61b4 /apex/com.android.art/lib/libart.so (art::DumpCheckpoint::Run(art::Thread*)+1172)
runtime.cc:655] native: #04 pc 006bf266 /apex/com.android.art/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+630)
runtime.cc:655] native: #05 pc 006be1ce /apex/com.android.art/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool)+2446)
runtime.cc:655] native: #06 pc 0065227d /apex/com.android.art/lib/libart.so (art::AbortState::DumpAllThreads(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*) const+445)
runtime.cc:655] native: #07 pc 0063984f /apex/com.android.art/lib/libart.so (art::Runtime::Abort(char const*)+1967)
runtime.cc:655] native: #08 pc 00025a23 /apex/com.android.art/lib/libartbase.so (std::__1::__function::__func<void (*)(char const*), std::__1::allocator<void (*)(char const*)>, void (char const*)>::operator()(char const*&&)+35)
runtime.cc:655] native: #09 pc 0001588f /system/lib/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_3::__invoke(char const*)+79)
runtime.cc:655] native: #10 pc 00006dbd /system/lib/liblog.so (__android_log_assert+285)
runtime.cc:655] native: #11 pc 0024dd11 /system/lib/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::swapBuffers(android::uirenderer::renderthread::Frame const&, bool, SkRect const&, android::uirenderer::FrameInfo*, bool*)+145)
runtime.cc:655] native: #12 pc 00257e78 /system/lib/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+1112)
runtime.cc:655] native: #13 pc 0025ab5f /system/lib/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+767)
runtime.cc:655] native: #14 pc 0024542d /system/lib/libhwui.so (android::uirenderer::WorkQueue::process()+285)
runtime.cc:655] native: #15 pc 0026cabf /system/lib/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+127)
runtime.cc:655] native: #16 pc 00015116 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+374)
runtime.cc:655] native: #17 pc 000147d9 /system/lib/libutils.so (thread_data_t::trampoline(thread_data_t const*)+457)
runtime.cc:655] native: #18 pc 000e6974 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+100)
runtime.cc:655] native: #19 pc 00078567 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+71)
runtime.cc:655] (no managed stack frames)
runtime.cc:655]
runtime.cc:655] "main" prio=10 tid=1 Native
2023-08-21 10:46:59.626 22025-22051 om.example.gam com.example.game A runtime.cc:655] | group="" sCount=1 dsCount=0 flags=1 obj=0x7233bc28 self=0xdd583810
runtime.cc:655] | sysTid=22025 nice=-10 cgrp=top-app sched=0/0 handle=0xeb954478
runtime.cc:655] | state=S schedstat=( 9562624174 4586979131 37249 ) utm=764 stm=191 core=3 HZ=100
runtime.cc:655] | stack=0xff229000-0xff22b000 stackSize=8192KB
runtime.cc:655] | held mutexes=
runtime.cc:655] native: #00 pc 00000b97 [vdso] (__kernel_vsyscall+7)
runtime.cc:655] native: #01 pc 0005ad68 /apex/com.android.runtime/lib/bionic/libc.so (syscall+40)
runtime.cc:655] native: #02 pc 0007725e /apex/com.android.runtime/lib/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+142)
runtime.cc:655] native: #03 pc 000e5b2e /apex/com.android.runtime/lib/bionic/libc.so (pthread_cond_wait+62)
runtime.cc:655] native: #04 pc 0025a146 /system/lib/libhwui.so (android::uirenderer::renderthread::DrawFrameTask::postAndWait()+182)
runtime.cc:655] native: #05 pc 0023922d /system/lib/libhwui.so (android::android_view_ThreadedRenderer_syncAndDrawFrame(_JNIEnv*, _jobject*, long long, _jlongArray*, int)+109)
runtime.cc:655] at android.graphics.HardwareRenderer.nSyncAndDrawFrame(Native method)
runtime.cc:655] at android.graphics.HardwareRenderer.syncAndDrawFrame(HardwareRenderer.java:433)
runtime.cc:655] at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:658)
runtime.cc:655] at android.view.ViewRootImpl.draw(ViewRootImpl.java:4101)
runtime.cc:655] at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3828)
runtime.cc:655] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3099)
runtime.cc:655] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
runtime.cc:655] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
runtime.cc:655] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
runtime.cc:655] at android.view.Choreographer.doCallbacks(Choreographer.java:796)
runtime.cc:655] at android.view.Choreographer.doFrame(Choreographer.java:731)
runtime.cc:655] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
runtime.cc:655] at android.os.Handler.handleCallback(Handler.java:938)
runtime.cc:655] at android.os.Handler.dispatchMessage(Handler.java:99)
runtime.cc:655] at android.os.Looper.loop(Looper.java:223)
runtime.cc:655] at android.app.ActivityThread.main(ActivityThread.java:7656)
runtime.cc:655] at java.lang.reflect.Method.invoke(Native method)
runtime.cc:655] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
runtime.cc:655] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
runtime.cc:655]
runtime.cc:655] "Signal Catcher" prio=10 tid=6 WaitingInMainSignalCatcherLoop
runtime.cc:655] | group="" sCount=1 dsCount=0 flags=1 obj=0x132c0228 self=0xdd58a810
runtime.cc:655] | sysTid=22035 nice=-20 cgrp=top-app sched=0/0 handle=0xd27e21e0
runtime.cc:655] | state=S schedstat=( 324261 0 1 ) utm=0 stm=0 core=3 HZ=100
runtime.cc:655] | stack=0xd26e7000-0xd26e9000 stackSize=1008KB
runtime.cc:655] | held mutexes=
runtime.cc:655] native: #00 pc 00000b99 [vdso] (__kernel_vsyscall+9)
runtime.cc:655] native: #01 pc 000ce821 /apex/com.android.runtime/lib/bionic/libc.so (__rt_sigtimedwait+33)
runtime.cc:655] native: #02 pc 00086c55 /apex/com.android.runtime/lib/bionic/libc.so (sigwait+69)
runtime.cc:655] native: #03 pc 00665f1d /apex/com.android.art/lib/libart.so (art::SignalCatcher::WaitForSignal(art::Thread*, art::SignalSet&)+461)
runtime.cc:655] native: #04 pc 006648ff /apex/com.android.art/lib/libart.so (art::SignalCatcher::Run(void*)+479)
runtime.cc:655] native: #05 pc 000e6974 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+100)
runtime.cc:655] native: #06 pc 00078567 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+71)
runtime.cc:655] (no managed stack frames)
runtime.cc:655]
2023-08-21 10:46:59.626 22025-22051 om.example.gam com.example.game A runtime.cc:655] "perfetto_hprof_listener" prio=10 tid=7 Native (still starting up)
runtime.cc:655] | group="" sCount=1 dsCount=0 flags=1 obj=0x0 self=0xdd586210
runtime.cc:655] | sysTid=22036 nice=-20 cgrp=top-app sched=0/0 handle=0xd26e11e0
runtime.cc:655] | state=S schedstat=( 453304 0 8 ) utm=0 stm=0 core=0 HZ=100
runtime.cc:655] | stack=0xd25e6000-0xd25e8000 stackSize=1008KB
runtime.cc:655] | held mutexes=
runtime.cc:655] native: #00 pc 00000b97 [vdso] (__kernel_vsyscall+7)
runtime.cc:655] native: #01 pc 000ccf9c /apex/com.android.runtime/lib/bionic/libc.so (read+28)
runtime.cc:655] native: #02 pc 0001aca2 /apex/com.android.art/lib/libperfetto_hprof.so (void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, ArtPlugin_Initialize::$_29> >(void*)+306)
runtime.cc:655] native: #03 pc 000e6974 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+100)
runtime.cc:655] native: #04 pc 00078567 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+71)
runtime.cc:655] (no managed stack frames)
runtime.cc:655]
runtime.cc:655] "ADB-JDWP Connection Control Thread" prio=10 tid=8 WaitingInMainDebuggerLoop
runtime.cc:655] | group="" sCount=1 dsCount=0 flags=1 obj=0x132c02a0 self=0xdd588c10
runtime.cc:655] | sysTid=22037 nice=-20 cgrp=top-app sched=0/0 handle=0xd25e01e0
runtime.cc:655] | state=S schedstat=( 1278972 202074 9 ) utm=0 stm=0 core=1 HZ=100
runtime.cc:655] | stack=0xd24e5000-0xd24e7000 stackSize=1008KB
runtime.cc:655] | held mutexes=
runtime.cc:655] native: #00 pc 00000b99 [vdso] (__kernel_vsyscall+9)
runtime.cc:655] native: #01 pc 000cf496 /apex/com.android.runtime/lib/bionic/libc.so (__ppoll+38)
runtime.cc:655] native: #02 pc 00083979 /apex/com.android.runtime/lib/bionic/libc.so (poll+105)
runtime.cc:655] native: #03 pc 0000a493 /apex/com.android.art/lib/libadbconnection.so (adbconnection::AdbConnectionState::RunPollLoop(art::Thread*)+1171)
runtime.cc:655] native: #04 pc 000086d2 /apex/com.android.art/lib/libadbconnection.so (adbconnection::CallbackFunction(void*)+1666)
runtime.cc:655] native: #05 pc 000e6974 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+100)
runtime.cc:655] native: #06 pc 00078567 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+71)
runtime.cc:655] (no managed stack frames)
runtime.cc:655]
runtime.cc:655] "HeapTaskDaemon" prio=5 tid=9 WaitingForTaskProcessor
runtime.cc:655] | group="" sCount=1 dsCount=0 flags=1 obj=0x132c0750 self=0xdd584610
runtime.cc:655] | sysTid=22039 nice=4 cgrp=top-app sched=0/0 handle=0xbd6701e0
runtime.cc:655] | state=S schedstat=( 1740376612 449504217 1458 ) utm=116 stm=57 core=0 HZ=100
runtime.cc:655] | stack=0xbd56d000-0xbd56f000 stackSize=1040KB
runtime.cc:655] | held mutexes=
runtime.cc:655] native: #00 pc 00000b97 [vdso] (__kernel_vsyscall+7)
runtime.cc:655] native: #01 pc 0005ad68 /apex/com.android.runtime/lib/bionic/libc.so (syscall+40)
runtime.cc:655] native: #02 pc 001d82ec /apex/com.android.art/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+108)
runtime.cc:655] native: #03 pc 001d8273 /apex/com.android.art/lib/libart.so (art::ConditionVariable::Wait(art::Thread*)+35)
runtime.cc:655] native: #04 pc 0034a036 /apex/com.android.art/lib/libart.so (art::gc::TaskProcessor::GetTask(art::Thread*)+630)
runtime.cc:655] native: #05 pc 0034aa64 /apex/com.android.art/lib/libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*)+84)
runtime.cc:655] native: #06 pc 005591f5 /apex/com.android.art/lib/libart.so (art::VMRuntime_runHeapTasks(_JNIEnv*, _jobject*)+53)
runtime.cc:655] at dalvik.system.VMRuntime.runHeapTasks(Native method)
runtime.cc:655] at java.lang.Daemons$HeapTaskDaemon.runInternal(Daemons.java:531)
runtime.cc:655] at java.lang.Daemons$Daemon.run(Daemons.java:139)
runtime.cc:655] at java.lang.Thread.run(Thread.java:923)
2023-08-21 10:46:59.626 22025-22051 om.example.gam com.example.game A runtime.cc:655]
runtime.cc:655] "FinalizerDaemon" prio=5 tid=10 Waiting
runtime.cc:655] | group="" sCount=1 dsCount=0 flags=1 obj=0x132c0318 self=0xdd587010
runtime.cc:655] | sysTid=22041 nice=4 cgrp=top-app sched=0/0 handle=0xbd45e1e0
runtime.cc:655] | state=S schedstat=( 27091640 2409459 226 ) utm=1 stm=1 core=0 HZ=100
让这个问题变得非常奇怪的是,当使用另一个 png 文件作为可绘制对象时,一切正常。例如,当使用这个 png 文件时,一切都可以正常工作,或者如果我只是使用 Android 内部图像或矢量资产。所以代码本身是正确的。但是当使用窗口png文件
时,我收到这个奇怪的错误。我使用相同的程序(Inkscape)创建了两个PNG文件。它们都是原始的矢量图形,我使用 Inkscape 将它们转换为 png。所以我的问题是,有没有人知道为什么 Android 对自制的窗口图像有问题,而对自制的温度计图像没有问题?
答: 暂无答案
评论