maxkomarychev / react-native-ultimate-config

Config that works
MIT License
262 stars 31 forks source link

R8 fails due to Generics in ProGuard Rules #43

Closed tschanz-pcv closed 3 years ago

tschanz-pcv commented 3 years ago

Describe the bug

When building the app for release, it fails with the following error message:

> Task :app:transformClassesAndResourcesWithR8ForDevdefaultshRelease FAILED
/Users/runner/work/1/s/android/app/proguard-rules.pro:67:25: R8: Use of generics not allowed for java type.

This is because of the ProGuard rule mentioned in the quickstart guide:

-keepclassmembers class <APPLICATION ID>.BuildConfig {
   public static <fields>;
}

I could fix it by replacing <APPLICATION ID>.BuildConfig with the import path of the BuildConfig as it is in MainApplication.java.

Steps to Reproduce

  1. Setup the Project with ProGuard and RNUC as in the Guide
  2. Build the Project for Release:
    npm run rnuc config/falvor/env.dev && cross-env BUILD_TARGET=flavor ./android/gradlew -p android clean :app:assembleFlavorRelease
  3. It will fail

Expected behavior

It should build the app successfully.

Stacktraces, logs, screenshots

> Task :app:transformClassesAndResourcesWithR8ForDevdefaultshRelease FAILED
/Users/runner/work/1/s/android/app/proguard-rules.pro:67:25: R8: Use of generics not allowed for java type.

Environment

Integration option

Env file

Example of env file that is causing problems

Irrelevant

OS

Packages

Run react-native info and post below:

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 885.38 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.18.4 - ~/.nvm/versions/node/v12.18.4/bin/node
    Yarn: Not Found
    npm: 6.14.6 - ~/.nvm/versions/node/v12.18.4/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.1, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK:
      API Levels: 26, 27, 28, 29, 30
      Build Tools: 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2
      System Images: android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom_64
      Android NDK: 17.2.4988734
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.1/12A7403 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.7 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
maxkomarychev commented 3 years ago

hi @tschanz-pcv, I'm not entirely sure what is the problem? is documentation not clear enough about proguard rules? should it say <PACKAGE_NAME> instead? feel free to open PR suggesting a fix, thank you

tschanz-pcv commented 3 years ago

I'm sorry as I'm not very knowledgeable about Gradle I interpreted this as a generic just like <fields> and not a replacement you expect the user to make. Maybe use something else than <> and mention that you expect the user to replace this with the actual package name in the guide?

maxkomarychev commented 3 years ago

hey @tschanz-pcv , I clarified docs a little in this commit: 3a9c461 I hope it makes more sense now. thank you