Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashing with fill property on SVG #1061

Closed
vinicius98s opened this issue Jul 29, 2019 · 40 comments
Closed

App crashing with fill property on SVG #1061

vinicius98s opened this issue Jul 29, 2019 · 40 comments

Comments

@vinicius98s
Copy link

Bug

Hello,

When I run the application with react-native run-android everything goes well, but when I try to generate an apk for testing as soon as I open some screen with the SVG (that contains the fill property) it crashes.

image

I ran it with the adb logcat and this is the error message I'm getting:

E/AndroidRuntime( 5567): java.lang.IllegalStateException: java.lang.NoSuchFieldException: fill
E/AndroidRuntime( 5567): 	at com.horcrux.svg.t.a(Unknown Source)
E/AndroidRuntime( 5567): 	at com.horcrux.svg.j.b(Unknown Source)
E/AndroidRuntime( 5567): 	at com.horcrux.svg.j.a(Unknown Source)
E/AndroidRuntime( 5567): 	at com.horcrux.svg.t.d(Unknown Source)
E/AndroidRuntime( 5567): 	at com.horcrux.svg.x.a(Unknown Source)
E/AndroidRuntime( 5567): 	at com.horcrux.svg.x.j(Unknown Source)
E/AndroidRuntime( 5567): 	at com.horcrux.svg.x.onDraw(Unknown Source)

Environment info

React native info output:

  React Native Environment Info:
    System:
      OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
      CPU: (4) x64 Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz
      Memory: 133.89 MB / 7.70 GB
      Shell: 5.5.1 - /usr/bin/zsh
    Binaries:
      Node: 10.15.2 - /usr/bin/node
      npm: 6.10.1 - /usr/local/bin/npm
    SDKs:
      Android SDK:
        API Levels: 23, 28, 29
        Build Tools: 28.0.3, 29.0.0
        System Images: android-21 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.10 => 0.59.10 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Library version: 9.5.3

I initially installed the version 9.5.1, and upgraded to try to solve this problem but it didn't

Steps To Reproduce

  1. Generate an apk with assembleRelease
  2. Open the app
    ...

Describe what you expected to happen:

  1. Run without crashing

Reproducible sample code

This is the SVG making the app crash (if I remove the fill prop and build my apk it runs normally)

<Svg fill="#f09e3e" height="64px" viewBox="-4 0 480 480.00003" width="64px">
    <Path d="m184 288h16v16h-16zm0 0" />
    <Path d="m136 288h16v16h-16zm0 0" />
    <Path d="m88 288h16v16h-16zm0 0" />
    <Path d="m232 288h16v16h-16zm0 0" />
    <Path d="m224 160h16.574219l4.25 56.601562 15.953125-1.203124-4.152344-55.398438h174.75l-22.800781 304h-56.574219v16h64c4.195312.011719 7.683594-3.21875 8-7.398438l23.425781-312.601562h16.574219c4.417969 0 8-3.582031 8-8v-40c0-4.417969-3.582031-8-8-8h-96v-96c0-4.417969-3.582031-8-8-8h-32c-4.417969 0-8 3.582031-8 8v96h-96c-4.417969 0-8 3.582031-8 8v40c0 4.417969 3.582031 8 8 8zm112-144h16v88h-16zm-104 104h224v24h-224zm0 0" />
    <Path d="m40 480h256c22.082031-.027344 39.972656-17.917969 40-40v-32c0-4.417969-3.582031-8-8-8h-.207031c10.941406-14.128906 10.941406-33.871094 0-48h.207031c4.417969 0 8-3.582031 8-8 .011719-31.625-12.503906-61.972656-34.808594-84.390625l-2.917968-44.136719-16 1.054688 1.910156 28.863281c-20.007813-13.929687-43.804688-21.394531-68.183594-21.390625h-96c-66.242188.074219-119.9257812 53.757812-120 120 0 4.417969 3.582031 8 8 8h.207031c-10.941406 14.128906-10.941406 33.871094 0 48h-.207031c-4.417969 0-8 3.582031-8 8v32c.0273438 22.082031 17.917969 39.972656 40 40zm280-40c0 13.253906-10.746094 24-24 24h-256c-13.253906 0-24-10.746094-24-24v-24h304zm-79.398438-40 63.796876-46.398438c10.875 4.042969 17.285156 15.296876 15.21875 26.714844-2.066407 11.414063-12.015626 19.707032-23.617188 19.683594zm-24.800781-1.742188-69.402343-46.257812h133zm-95.800781-158.257812h96c54.3125.0625 99.453125 41.855469 103.695312 96h-303.390624c4.242187-54.144531 49.386718-95.9375 103.695312-96zm-104 136c0-13.253906 10.746094-24 24-24h77.601562l72 48h-149.601562c-13.253906 0-24-10.746094-24-24zm0 0" />
    <Path d="m208 256h16v16h-16zm0 0" />
    <Path d="m160 256h16v16h-16zm0 0" />
    <Path d="m112 256h16v16h-16zm0 0" />
    <Path d="m280.019531 184.566406 15.960938-1.140625 1.144531 16-15.960938 1.140625zm0 0" />
  </Svg>
@fgagneten
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

@vinicius98s
Copy link
Author

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

This solved the problem, thank you!

@quocbaovu15101996
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

save my life

@huuphudn2017
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

Tks you so much ^^

@MujtabaFR
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

thanks a lot ..
just to clarify the path.. it's android/app/proguard-rules.pro

@oeduardoal
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

It's work! Tks! 🚀

@joeybronner
Copy link

Great, it works like a charm 👍

@BiplovQss
Copy link

-keep public class com.horcrux.svg.** {*;}

thanks. It worked.

@drb1
Copy link

drb1 commented Dec 8, 2020

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

after adding this crash is gone but i got

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

java.io.FileNotFoundException: ......android/app/keep public class com.horcrux.svg.** {* (No such file or directory)

error in release mode.

@sverano
Copy link

sverano commented Aug 20, 2021

thanks @fgagneten It worked for me.

@muskanjain16
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

save my life

My life also dude :)

@neilfranci
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

It's 2021 you have safe my life.

@jyotiska
Copy link

It's almost 2022, you still have saved my life.

@renomi
Copy link

renomi commented Dec 15, 2021

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

save my life

My life also dude :)

It needs patience and tears— you still have saved my life, thank you dude!

@navidkhalilian
Copy link

You still have saved my life. Thanks dude!

@afilp
Copy link

afilp commented Jan 21, 2022

It's 2022, you still have saved my life too, thanks! :-)

@Dalu26
Copy link

Dalu26 commented Jan 21, 2022

This is a lifesaver!!

@briankiboino
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

This solved the problem, thank you!

Worked for me!!!

@thespacemanatee
Copy link

It's almost 2023 and this saved my life as well.

@TaufanP
Copy link

TaufanP commented Jun 14, 2022

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

It's mid 2022 and you saved another soul :) thanks a ton!

@midoalone
Copy link

you saved my entire life, spent dozen of hours trying to get a solution for this, thanks

@monkeyK1n9
Copy link

please how do you solve this issue in Expo managed workflow?

@Manil-SoftNEP
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

thanks a lot .. just to clarify the path.. it's android/app/proguard-rules.pro

After employing this the app worked fine on actual devices (Galaxy M02 and XIAOMI MI A2). But the crashes persist on the emulator (Pixel 4).

@Ali-Goher-Shabir
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

Saved my life too. :) 👍

@isurugg
Copy link

isurugg commented Aug 17, 2022

Saved my life too. :) :*

@jimgitonga
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

This solved mine 2022 still worked hurray

@sqlsystems
Copy link

Oh my gosh! Nice! It worked very well!

@rodrigodiasf1984
Copy link

@drb1 have you managed to solve this error? I've got the same error after adding the --keep public class com.horcrux.svg
image
image

@raphaelBbs
Copy link

@drb1 have you managed to solve this error? I've got the same error after adding the --keep public class com.horcrux.svg image image

Have you resolve your problem, I have the same error

@stephanrotolante
Copy link

Saved my life Feb 2023 🚀

@MuhammadAbdullah54321
Copy link

Suggested solution worked like charm .... had to spend a lot of time on it.

Just in case if anyone else is still facing same issue and is using some other libraries as well ::
I had to to include all these other rules as well to make it work

-keep class com.swmansion.reanimated.** { ; }
-keep class com.facebook.hermes.unicode.
* { ; }
-keep class com.facebook.jni.
* { ; }
-keep class com.facebook.react.turbomodule.
* { ; }
-keep public class com.horcrux.svg.
* {*;}

@twocs
Copy link

twocs commented Mar 10, 2023

@MuhammadAbdullah54321 said

Suggested solution worked like charm .... had to spend a lot of time on it.

Just in case if anyone else is still facing same issue and is using some other libraries as well :: I had to to include all these other rules as well to make it work

-keep class com.swmansion.reanimated.** { ; }
-keep class com.facebook.hermes.unicode.
* { ; }
-keep class com.facebook.jni.
* { ; }
-keep class com.facebook.react.turbomodule.
* { ; }
-keep public class com.horcrux.svg.
* {*;}

This is very interesting, but how did you identify all the libraries that were needed?

@ducpt-bili
Copy link

Save me. Just curious why in the document not mention this :(

@bhagwandas
Copy link

My app uses vis.js in WebView.

It was crashing for this reason on one mobile(Samsung M31, Android 12) but on other phones, it worked well.

On adding this in proguard-rules.pro, it stopped crashing in that mobile but it became very slow in drawing vis.js network diagrams. But in other mobiles, it runs pretty smooth.

Any ideas on why this happened?

@jlag34
Copy link

jlag34 commented May 9, 2023

For anyone using expo, add this to your app.config.js/app.json:

  'expo': {
    'plugins': [
      [
        'expo-build-properties',
        {
          'android': {
            'enableProguardInReleaseBuilds': true,
            'extraProguardRules': '-keep public class com.horcrux.svg.** {*;}'
          }
        }
      ]
    ],
  }

@IamGideonIdoko
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

One line that saves. Thanks!

@DevicyKenitou
Copy link

For anyone using expo, add this to your app.config.js/app.json:

  'expo': {
    'plugins': [
      [
        'expo-build-properties',
        {
          'android': {
            'enableProguardInReleaseBuilds': true,
            'extraProguardRules': '-keep public class com.horcrux.svg.** {*;}'
          }
        }
      ]
    ],
  }

Big thanks to you ! 🤩

@FarhanKhan1815
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

omg god bless you my friend it really works

@thachsteven
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

You save my day. Tks a lot

@React-RN-Pratik
Copy link

You have to add:

-keep public class com.horcrux.svg.** {*;}

in proguard-rules.pro (app)

Thanks for the answer it helps me lot.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests