The SVG file works fine in the emulator, but gives an error in the real device?

I am using an SVG file in My Project to display an image. It works fine in the emulator, but gave an error in the real device.

The 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 for this?

EDIT: solution

 imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); 

add this line to your code.

+4
source share
1 answer

I did not use ImageViews, but placed SVG in the picture. I put the image in a custom PictureHolder class that gave Picture x and y float values. Then I used drawPicture () to put the image on the canvas. I could not force the solution imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); work. Using the same logic, I turned off hardware acceleration for the entire application in AndroidManifest.

 <application android:hardwareAccelerated="false" 

Not perfect, but it worked for me without a noticeable loss in performance.

0
source

Source: https://habr.com/ru/post/1501294/


All Articles