3

I am using a SVG file in My Project to show Image. It's run fine in the emulator but gave error in the real device.

Error is below :

E/AndroidRuntime(23215): java.lang.UnsupportedOperationException
E/AndroidRuntime(23215): at android.view.GLES20Canvas.drawPicture(GLES20Canvas.java:911)
E/AndroidRuntime(23215):at android.graphics.drawable.PictureDrawable.draw(PictureDrawable.java:73)

What is the reason Behind of this?

EDIT : Solution

imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

add this line to your code.

Akarsh M
  • 1,629
  • 2
  • 24
  • 47
  • 2
    See the answer to this similar question. http://stackoverflow.com/questions/18356098/using-vector-image-in-android-svg-android/18358672 – Paul LeBeau Sep 09 '13 at 18:33
  • One more thing is "If In the SVG file , there is 4 images like as grid layout in single row and I want to choose only 2 image when I parse the SVG" what is the solution for this ? @BigBadaboom – Akarsh M Sep 10 '13 at 06:22
  • I don't understand what you are asking. It might be best to start a new question so you can explain further. – Paul LeBeau Sep 10 '13 at 11:09
  • @BigBadaboom: I have added a new question .. have a look on it http://stackoverflow.com/questions/18713383/a-svg-image-have-6-icon-and-need-to-choose-one – Akarsh M Sep 10 '13 at 13:07

1 Answers1

0

I was not using ImageViews but placing the SVG in a Picture. I put the Picture in a custom PictureHolder class that gave the Picture x and y float values. I then used drawPicture() to put the Picture on a canvas. I couldn't get the imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); solution to work. Using the same logic I turned off hardware acceleration for the whole app in the AndroidManifest.

<application
    android:hardwareAccelerated="false"

Not ideal but it worked for me with no noticeable loss of performance.

TTransmit
  • 3,270
  • 2
  • 28
  • 43