1

I have two activities: one with some options and one with a web view. When I try and switch activities to the activity with a WebView, my application keeps crashing in the emulator.

Here is what my logcat says:

2020-04-02 11:16:01.138 8018-8018/com.funnidevelopers.youtubeapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.funnidevelopers.youtubeapp, PID: 8018
    java.lang.RuntimeException: Canvas: trying to draw too large(276623424bytes) bitmap.
        at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)

Can someone please give me a solution to this error?

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
Danny
  • 19
  • 2
  • your problem is that you are trying to draw too huge bitmap in that activity so problem is not about switching activities but drawing on the canvas. you need to identify where all of this things are happening and maybe check this stackoverflow post https://stackoverflow.com/questions/39111248/canvas-trying-to-draw-too-large-bitmap-when-android-n-display-size-set-larger – Bacho Kurtanidze Apr 02 '20 at 10:25
  • Edit question with source code that is giving an error – Ramana V V K Apr 02 '20 at 10:37

1 Answers1

0

Follow these points to avoid this kind of issues

For local files

  • Use your large image from drawable-nodpi folder (Incase folder not there create and move your large image files)

For server images

  • Use glide to load your files

    Glide.with(context).load("url").override(yourImageWidth, yourImageHeight); into(imageView)

Community
  • 1
  • 1
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159