react-native: Cannot resolve symbol 'ReactNativeFlipper' - When building release build variant
New Version
0.71.1
Old Version
0.70.6
Build Target(s)
Android - Release Build Variant
Output of react-native info
✗ react-native info
warn Package rn-fetch-blob contains invalid configuration: "dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Fetching system and libraries information...
System:
OS: macOS 13.1
CPU: (10) arm64 Apple M1 Pro
Memory: 40.48 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.3.0 - ~/.nvm/versions/node/v19.3.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v19.3.0/bin/yarn
npm: 9.2.0 - ~/.nvm/versions/node/v19.3.0/bin/npm
Watchman: 2023.01.23.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 19.0.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: ^10.0.0 => 10.1.3
react: 18.2.0 => 18.2.0
react-native: 0.71.1 => 0.71.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Issue and Reproduction Steps
When I change Build Variant to Release, it builds successfully but this error comes up when clicking Run ‘app’. And hovering over ‘ReactNativeFlipper’ shows Cannot resolve symbol 'ReactNativeFlipper'
.
.../MainApplication.java:61: error: cannot find symbol
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
^
symbol: variable ReactNativeFlipper
location: class MainApplication
Everything works fine on debug
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 9
- Comments: 17 (3 by maintainers)
In my case when I need to building release app, I just make a copy
ReactNativeFlipper.java
toandroid/app/src/main/java/com/my_project/ReactNativeFlipper.java
then I can building it.ReactNativeFlipper.java
content:Just comment this code when you only want to run on emulator and undo when you want to build in release
Hi guys, I have the same issue and this is the way I fix it.
People who create a project using
npx react-native init this_is_package_name
.import
ofReactNativeFlipper.java
inrelease
folderHope my comment can help people that have the same issue as me
This is not the solution and will result in deplicated class + crash at developer time. You should have only two
ReactNativeFlipper.java
files:You can copy the content from the template. If the issue persists open a separate issue.
This file solves the
assembleRelease
but crashes when I try to runreact-native run-android
because is a duplicated class.Any solution at this point? I can’t find it.
After some investigating, I realized that I was not adding a release folder that contained that ReactNativeFlipper.java code.
I was missing this file in src/release/com/packagename/ReactNativeFlipper.java
https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.71.1/RnDiffApp/android/app/src/release/java/com/rndiffapp/ReactNativeFlipper.java
Closing the issue now.
My issue was that I renamed my package, but did not update the package structure in the
release
directory (note that there aredebug
,main
ANDrelease
directories).I had the same issue and @LuongTruong comment helped me solve it, so even if this issue is closed, I’m going to write this down in case someone else has this issue.
I had everything set up correctly between main, debug and release folders. My issue was that my app has flavors, and app package ids end with
.dev
,.qa
and.prod
. I was not changing app package id inReactNativeFlipper.java
file correctly for.qa
and.prod
release builds, so the release build did not now whatReactNativeFlipper
class was as it had a different package id. When I added modifying package id for that file in my build scripts, everything started working again.