facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.2k stars 24.33k forks source link

cannot find symbol ReactNativeFlipper for release build #39657

Closed VaiteaBimOne closed 1 year ago

VaiteaBimOne commented 1 year ago

Description

I'm on react-native 72.4. While doing ./gradlew :app:assembleRelease :app:bundleRelease I have the error:

> Task :app:compileReleaseJavaWithJavac FAILED
/Users/runner/work/1/s/android/app/src/main/java/com/***/***/MainApplication.java:67: error: cannot find symbol
    ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
    ^
  symbol:   variable ReactNativeFlipper
  location: class MainApplication

I have 3 env (debug, internal and release) from buildTypes

buildTypes {
        debug {
            signingConfig signingConfigs.debug
            matchingFallbacks = ['debug', 'release', 'internal']

        }
        internal {
            matchingFallbacks = ['release', 'debug', 'internal']
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            matchingFallbacks = ['debug', 'release', 'internal']
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

I added the ReactNativeFlipper.java file in all my env except main .../android/app/src/debug/java/com/***/***/ReactNativeFlipper.java .../android/app/src/internal/java/com/***/***/ReactNativeFlipper.java .../android/app/src/release/java/com/***/***/ReactNativeFlipper.java

Now I can build and generate apks for internal and debug but the issue is with release. The only way to make it work is to have the ReactNativeFlipper.java in main with MainApplication.java but that cause the build to fail for internal and debug for duplicate class of ReactNativeFlipper.

Thanks!

React Native Version

0.72.4

Output of npx react-native info

System:
  OS: macOS 13.3.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 94.22 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: ~/.nvm/versions/node/v18.18.0/bin/node
  Yarn:
    version: 1.22.19
    path: /usr/local/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.0/bin/npm
  Watchman:
    version: 2022.09.05.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.11.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.1
      - iOS 16.1
      - macOS 13.0
      - tvOS 16.1
      - watchOS 9.1
  Android SDK:
    API Levels:
      - "23"
      - "28"
      - "30"
      - "31"
      - "33"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 34.0.0
    System Images:
      - android-28 | ARM 64 v8a
      - android-30 | ARM 64 v8a
      - android-30 | Intel x86 Atom_64
      - android-31 | ARM 64 v8a
      - android-31 | Intel x86 Atom_64
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2021.2 AI-212.5712.43.2112.8815526
  Xcode:
    version: 14.1/14B47b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.16.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Steps to reproduce

when I run ./gradlew :app:assembleRelease :app:bundleRelease

Snack, screenshot, or link to a repository

./gradlew :app:assembleRelease :app:bundleRelease

github-actions[bot] commented 1 year ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
github-actions[bot] commented 1 year ago
:warning: Add or Reformat Version Info
:information_source: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
cortinico commented 1 year ago

I added the ReactNativeFlipper.java file in all my env except main .../android/app/src/debug/java/com/***/***/ReactNativeFlipper.java .../android/app/src/internal/java/com/***/***/ReactNativeFlipper.java .../android/app/src/release/java/com/***/***/ReactNativeFlipper.java

Your setup is correct. You probably have a typo somewhere that is causing the app/src/release/ to be ignored.

Please provide more context or use the reproducer template linked by the bot to reproduce your issue

VaiteaBimOne commented 1 year ago

@cortinico Hi! My bad! My release folder was in the gitignore and the flipper file was not pushed.