构建成功但应用程序不断崩溃-Android Studio

时间:2018-07-19 16:46:02

标签: android android-layout android-studio android-debug

我开始开发一个android应用程序,并且正在关注教程。在我开发了第一个布局并启动了模拟器之后。我收到“ App X已停止”错误。 谢谢

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

模拟器图像弹出文本

image of the emulator pop up text

logcat crashing text

logcat crashing text 2

logcat crashing text 3

2 个答案:

答案 0 :(得分:1)

您要上传的图片太大。您可以考虑使用类似Glide或Picasso的库来加载图像,它将为您调整大小,以便您不再占用内存或加载不合适的图像。您可以自己编写代码,但是这些库已经解决了问题。

答案 1 :(得分:1)

解决方案:尝试将(高分辨率)启动位图从drawable移至drawable-xxhdpi。

类似问题:请参阅此链接

“Canvas: trying to draw too large bitmap”