这个问题已经有了答案:
“Canvas: trying to draw too large bitmap” when Android N Display Size set larger than Small
9个答案
我开始开发一个android应用程序,我正在学习教程。在我开发了第一个布局并启动模拟器之后。我收到一个“app x has stopped”错误。
谢谢
07-19 16:35:19.113 8380-8380/? I/zygote: Not late-enabling -Xcheck:jni (already on)
07-19 16:35:19.364 8380-8380/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
07-19 16:35:19.554 8380-8387/? I/zygote: Debugger is no longer active
07-19 16:35:20.591 8380-8380/? I/InstantRun: starting instant run server: is main process
07-19 16:35:30.584 8380-8391/ma.ac.iav.equineupperrespiratoryguide I/zygote: NativeAllocBackground concurrent copying GC freed 2710(1039KB) AllocSpace objects, 0(0B) LOS objects, 70% free, 656KB/2MB, paused 2.481ms total 420.596ms
07-19 16:35:30.857 8380-8391/ma.ac.iav.equineupperrespiratoryguide I/zygote: NativeAllocBackground concurrent copying GC freed 76(32KB) AllocSpace objects, 0(0B) LOS objects, 70% free, 646KB/2MB, paused 13.672ms total 91.301ms
07-19 16:35:31.040 8380-8391/ma.ac.iav.equineupperrespiratoryguide I/zygote: NativeAllocBackground concurrent copying GC freed 57(43KB) AllocSpace objects, 0(0B) LOS objects, 70% free, 635KB/2MB, paused 5.447ms total 41.602ms
07-19 16:35:31.094 8380-8512/ma.ac.iav.equineupperrespiratoryguide D/OpenGLRenderer: HWUI GL Pipeline
07-19 16:35:31.310 8380-8512/ma.ac.iav.equineupperrespiratoryguide I/OpenGLRenderer: Initialized EGL, version 1.4
07-19 16:35:31.310 8380-8512/ma.ac.iav.equineupperrespiratoryguide D/OpenGLRenderer: Swap behavior 1
07-19 16:35:31.314 8380-8512/ma.ac.iav.equineupperrespiratoryguide W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
07-19 16:35:31.314 8380-8512/ma.ac.iav.equineupperrespiratoryguide D/OpenGLRenderer: Swap behavior 0
07-19 16:35:31.370 8380-8512/ma.ac.iav.equineupperrespiratoryguide D/EGL_emulation: eglCreateContext: 0xa0d05480: maj 2 min 0 rcv 2
07-19 16:35:31.479 8380-8512/ma.ac.iav.equineupperrespiratoryguide D/EGL_emulation: eglMakeCurrent: 0xa0d05480: ver 2 0 (tinfo 0xa0d03220)
07-19 16:35:31.660 8380-8380/ma.ac.iav.equineupperrespiratoryguide D/AndroidRuntime: Shutting down VM
--------- beginning of crash
07-19 16:35:31.676 8380-8380/ma.ac.iav.equineupperrespiratoryguide
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ma.ac.iav.equineupperrespiratoryguide, PID: 8380
java.lang.RuntimeException: Canvas: trying to draw too large(114307200bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)
at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:97)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:529)
at android.view.View.getDrawableRenderNode(View.java:19381)
at android.view.View.drawBackground(View.java:19317)
at android.view.View.draw(View.java:19114)
at android.view.View.updateDisplayListIfDirty(View.java:18073)
at android.view.View.draw(View.java:18851)
at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
at android.view.View.updateDisplayListIfDirty(View.java:18064)
at android.view.View.draw(View.java:18851)
at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
at android.view.View.updateDisplayListIfDirty(View.java:18064)
at android.view.View.draw(View.java:18851)
at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
at android.view.View.updateDisplayListIfDirty(View.java:18064)
at android.view.View.draw(View.java:18851)
at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
at android.view.View.updateDisplayListIfDirty(View.java:18064)
at android.view.View.draw(View.java:18851)
at android.view.ViewGroup.drawChild(ViewGroup.java:4214)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4000)
at android.view.View.draw(View.java:19126)
at com.android.internal.policy.DecorView.draw(DecorView.java:785)
at android.view.View.updateDisplayListIfDirty(View.java:18073)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:643)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:649)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:757)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2980)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2794)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2347)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArg
sCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
the layout design app
the xml file
模拟器弹出文本的图像
logcat crashing text
logcat crashing text 2
logcat crashing text 3
最佳答案
你正在上载的图像太大。看看使用glide或picasso这样的库加载图像,它会为您调整大小,这样您就不会内存不足或加载不适合的图像。你可以自己写代码,但这些库已经解决了这个问题。