1

I am using a vector image (svg) as a background in one layout. I added it with the menu

File -> New -> Vector Asset... 

and I have it as an .xml in my drawable folder.

When I generate the .apk file and install the app, when I go to the screen that has this layout with this image as background it crashes the app in some devices, throwing the error

android.content.res.Resources$NotFoundException. 

However, in other devices it works perfectly. For instance, it works with Android version 7.1.1, but crashes with version 8.

I know it may crash in devices with an Android version previous to Lollipop (5.0) but I am only testing with 6.0 and higher.

Has anyone face this issue?

Thanks in advance.

Paul LeBeau
  • 97,474
  • 9
  • 154
  • 181
manuel
  • 356
  • 2
  • 9
  • https://stackoverflow.com/questions/36867298/using-android-vector-drawables-on-pre-lollipop-crash – AskNilesh Sep 13 '18 at 10:45
  • 2
    Possible duplicate of [Using android vector Drawables on pre Lollipop crash](https://stackoverflow.com/questions/36867298/using-android-vector-drawables-on-pre-lollipop-crash) – MohammadReza Alagheband Sep 13 '18 at 10:51
  • But I am not intalling the app in any device previous to 5.0. I just don´t understand why same apk works in 7.1.1 but no in 8.0 device. – manuel Sep 13 '18 at 11:04
  • How are you generating the apk? Are you using "Run" or "Build -> Build APK"? They produce different results. "Run" will produce an apk that only has the necessary resources etc to run on your current debugging device / emulator. "Build -> Build APK" will produce an apk that should run on any device that matches the specifications in your manifest. – Sound Conception Sep 13 '18 at 11:48
  • Hi. If I "Run" the app from Android Studio, it will work in some of the devices I connect, but not in another ones. All of them higher than Lollipop. Same when I create the signed .apk, some devices throw the error Resource$NotFoundExcepcion, another work perfectly. I have used before vector images in more screens in my app, and it always worked fine in all the devices. It seems something might be wrong with this SVG. But the only different I see is this one has a color gradient. – manuel Sep 13 '18 at 13:39

1 Answers1

0

this isnt the answer you were looking for, but as you are working with SVG's perhaps its what you want https://github.com/MegatronKing/SVG-Android

About

SVG-Android is a support library for showing svg images in android 4.0+ .

faster than png, vector and iconfont, the decoding stage costs less time.
better performance and expression than png even using a huge image.
support tint, alpha, size, selector whether in java code or xml code.
shrink the apk size, it can reduce the image size obviously.
support drawable animtions with some assigned animators.
kwip000
  • 21
  • 6