react-native-flipper 0.48.0 breaks building Android in Release, presumably due to https://github.com/facebook/flipper/commit/03b231703ba1e609d8b5d31d71d07c57be1f0b29
Version 0.47.0 did not have this problem, although it had the problem in #1274, which the above change was trying to address.

Very simple.
npx react-native init Testcd Testyarn add react-native-flipperThe build will fail, but if you change the version of react-native-flipper from 0.48.0 to 0.47.0, then it will succeed.
Since this is a build failure with a default-initialized React Native project, the only variable being react-native-flipper itself, I can't think of any relevant environment info to add, but feel free to ask if you think there's something I've missed.
Same stuff
May be need to create debug folder and return module for auto linking by BuildConfig.DEBUG value and with reflection return FlipperModule instance if debug is true. (Very the same as for initializeFlipper from installation part)
Because root cause is auto generated PackageList.java
public ArrayList<ReactPackage> getPackages() {
return new ArrayList<>(Arrays.<ReactPackage>asList(
new MainReactPackage(mConfig),
new FlipperPackage(), // <- it is here in release
...
Assumption:
List<NativeModule> createNativeModules(ReactApplicationContext reactContext)
if (BuildConfig.DEBUG) {
try {
Class<?> flipperModuleClass = Class.forName("com.facebook.flipper.reactnative.FlipperModule");
return Collections.<NativeModule>singletonList((NativeModule)
flipperModuleClass
.getMethod("init", ReactApplicationContext.class)
.invoke(null, reactContext));
} catch ...
public class FlipperModule extends ReactContextBaseJavaModule {
public static final String NAME = "Flipper";
public static FlipperModule init(ReactApplicationContext reactContext) {
return new FlipperModule(FlipperReactNativeJavaScriptPluginManager.getInstance(), reactContext);
} ...
Hope it make sense 🧑💻
@passy I do not know whom I may tag here, so let it be you :)
@ObidosDev I solved on my project, I sent a PR that can resolve this problem here
Note that the above PR did _not_ fix this bug.
(as @b3coded also acknowledged... I'm not criticizing their effort, just clarifying for folks looking at this)
@TheAlmightyBob Yes, when I ran with my local changes probbably I got some cache and my test application worked. So now I'm trying to check if RN CLI can help us
Something like this
@b3coded @passy Perhaps react-native-flipper should just opt-out of autolinking on Android for now and provide instructions for debug-only manual linking?
(or perhaps it could provide a release-only dummy version of FlipperPackage?? I'm less-certain if that would work though...)
@TheAlmightyBob for now, I believe that will be a good idea use manual linking
@b3coded @TheAlmightyBob I have described approach above which worked for me on my local changes WITH auto linking only for DEBUG mode and just ignore flipper for RELEASE. So I will try to prepare my changes tomorrow with new PR
@TheAlmightyBob I ran your PR in the FlipperExample and it builds (tested with Debug and Release variants and it's working), I forgot to add a FlipperPackage.java to android/main folder, Thank you !
@ObidosDev #1329 should also fix this (sounds like it did for @b3coded ), and I think is a bit cleaner than using reflection. But if you think you have a better solution that you still want to submit that's fine.
@TheAlmightyBob your solution just ignoring the flipper auto linking?
@ObidosDev No, #1329 still works with autolinking.
Manual linking is just a workaround that can be temporarily applied in a consuming React Native app until this bug gets fixed.
I am experiencing this issue as well. npx react-native run-android --variant=release fails for me with missing Flipper classes
@micnguyen if you're using react-native-flipper dependency, install the 0.47.0 version
@micnguyen Note that @b3coded 's tip will fix the build but mean that your release APK includes a few MB of Flipper libraries.
If that concerns you, manual linking is an effective workaround... but it's a little nontrivial and hopefully it won't be too much longer to get the fix in for this 🤞
Thanks for the advice. As we are not considering releasing any time soon, I'll eagerly await for your PR that will fix it: https://github.com/facebook/flipper/pull/1329 👍
The fix has been released as [email protected].
Most helpful comment
The fix has been released as [email protected].