4

My react native app is crashing after enabling R8 by making the following changes in app/build.gradle.

The build is successful but the app crashes on the run-time.

Here's the code:

enter image description here

sakshya73
  • 5,570
  • 5
  • 22
  • 41

1 Answers1

3

It took me days to debug this issue, so I wanted to write the solution that worked for me. I was trying to fix the issue by adding the rules in proguard-rules.pro file for the packages that I was using but the main issue was in app/build.gradle file only.

The issues are simple ones but were hard to get. Here are the issues:

  1. By default react-native run-android builds the apk in debug mode but R8 obfuscation doesn’t work in debug mode.
  2. debuggable true -> My app started working fine after making debuggable false
  3. issue with the packages -> There are multiple packages that are responsible for the app crash for eg. Firebase. So, for that, you need to check through all your packages and add the rules that are required by proguard-rules.pro.
sakshya73
  • 5,570
  • 5
  • 22
  • 41
  • Could you share some concrete information on the issues you ran into and how you solved them? You can use the R8 bug tracker https://issuetracker.google.com/issues/new?component=326788. R8 should work just as well in debug mode as in release mode, and if you need rules for libraries, then that could be a sign of these libraries missing consumer keep rules. Adding "star" rules for packages should rarely be the answer. – sgjesse Oct 24 '22 at 07:47
  • Hi @sgjesse, can we get a log or warnings somewhere for the missing classes? As my app is still crashing without any logs. – sakshya73 Oct 25 '22 at 06:00
  • Not completely sure what you mean with missing classes. Please open an issue on the R8 bug tracker issuetracker.google.com/issues/new?component=326788, so we can gather more information. – sgjesse Oct 31 '22 at 11:34