Closed lorsk closed 1 year ago
In my case when I need to building release app, I just make a copy ReactNativeFlipper.java
to android/app/src/main/java/com/my_project/ReactNativeFlipper.java
then I can building it.
ReactNativeFlipper.java
content:
package com.myProject;
import android.content.Context;
import com.facebook.react.ReactInstanceManager;
public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
// Do nothing as we don't want to initialize Flipper on Release.
}
}
That works @Hermanyo
I want to mentioned, also tried creating a react native 0.71.0 project using npx react-native init my_project
and moved my code there and it seems to have worked too.
I used this helper when updating manually, and double checked I didn't miss anything but without that fix you mentioned it fails, very weird: https://react-native-community.github.io/upgrade-helper/?from=0.70.6&to=0.71.1
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
Closing the issue now.
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:package com.myProject; import android.content.Context; import com.facebook.react.ReactInstanceManager; public class ReactNativeFlipper { public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { // Do nothing as we don't want to initialize Flipper on Release. } }
This file solves the assembleRelease
but crashes when I try to run react-native run-android
because is a duplicated class.
Any solution at this point? I can't find it.
Just comment this code when you only want to run on emulator and undo when you want to build in release
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.
This is not the solution and will result in deplicated class + crash at developer time.
You should have only two ReactNativeFlipper.java
files:
android/app/src/debug/java/com/helloworld/ReactNativeFlipper.java
android/app/src/release/java/com/helloworld/ReactNativeFlipper.java
You can copy the content from the template. If the issue persists open a separate issue.
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:package com.myProject; import android.content.Context; import com.facebook.react.ReactInstanceManager; public class ReactNativeFlipper { public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { // Do nothing as we don't want to initialize Flipper on Release. } }
thanks work for me.
I think the appropriate location is in android/app/src/release/java/com/my_project/ReactNativeFlipper.java
that way it is only appended in release builds and not in debug mode.
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
of ReactNativeFlipper.java
in release
folderimport this_is_NEW_package_name; // <= please change this import
Hope my comment can help people that have the same issue as me
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 what ReactNativeFlipper
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.
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.
can you please provide your script? I'm facing same issue with wrong package name inside ReactNativeFlipper.java
For me the solution was to replace ReactNativeFlipper.java file on path: '/android/app/src/debug/java/com/terapify/ReactNativeFlipper.java' with the ReactNativeFlipper.java file we have in this path: android/app/src/release/java/com/terapify/ReactNativeFlipper.java
This file has this content:
/**
I'm using RN "0.71.8".
Hope it helps
any solution without create copy?
@Jonathanfd : I did not have to copy the version of android/app/src/release/java/com/terapify/ReactNativeFlipper.java to '/android/app/src/debug/java/com/terapify/ReactNativeFlipper.java'. After a lot of juggling, I just removed the ReactNativeFlipper.java from the "main" path. There are some suggestions to include the file in the "main" directory path, but I recommend against it as it starts throwing duplicate class errors.
In my case I've used the react-native-rename package to rename my project but, I don't know why, both release and debug folders (src/debug/java/com/... and src/release/java/com...) have not been renamed, including the entries in the respective ReactNativeFlipper.java files.
My issue was that I renamed my package, but did not update the package structure in the release
directory (note that there are debug
, main
AND release
directories).
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).
This worked for me. Thank you.
New Version
0.71.1
Old Version
0.70.6
Build Target(s)
Android - Release Build Variant
Output of
react-native info
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'
.Everything works fine on
debug