question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android - How to setup dependencies when Flipper is only used in debug builds?

See original GitHub issue

In my Application onCreate I have

if (BuildConfig.DEBUG) {
            SoLoader.init(this, false);
            if (FlipperUtils.shouldEnableFlipper(this)) {
                final FlipperClient client = AndroidFlipperClient.getInstance(this);
                client.addPlugin(new NetworkFlipperPlugin());
                client.addPlugin(new InspectorFlipperPlugin(this, DescriptorMapping.withDefaults()));
                client.addPlugin(CrashReporterPlugin.getInstance());
                client.start();
            }
        }

and in my app level build.gradle I have:

implementation 'com.facebook.flipper:flipper:0.16.2'
implementation 'com.facebook.soloader:soloader:0.5.1'

but, if my hunch is right… this means flipper is technically being shipped in release builds. How can I prevent this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
theGlenncommented, Mar 6, 2019

@ColtonIdle @passy I came up with this as a temporary working solution until it’s done in Flipper’s core package. https://github.com/theGlenn/flipper-android-no-op

dependencies {
  releaseImplementation 'com.github.theGlenn:flipper-android-no-op:0.1.0'
  debugImplementation 'com.facebook.soloader:soloader:0.6.0'
  debugImplementation 'com.facebook.flipper:flipper:0.15.0'
}
1reaction
ColtonIdlecommented, Mar 8, 2019

If a no-op variant isn’t needed (or deemed the right solution) then yes, docs would be helpful. I just came across another reddit comment that said they tried flipper, didn’t compile so they dropped it and haven’t used it since. (Unfortunately) I feel like setup instructions should be fairly comprehensive so new and old developers have as little friction as possible.

If you recommend debugCompile, then I would at least include something about it failing in release and giving the user the 3 (?) possible options forward. Something like the below:

Note: Flipper is intended to be used during debugging, which is why we recommend debugImplementation, but this will cause your release builds to fail. You can do one of the below to alleviate this.

  1. Create separate /debug and /release Application classes. Only include the flipper code in the /debug Application class.
  2. If you’d prefer to keep one application class, you can write your own class that acts as an initializer for all of your debugging tools including flipper. Then you can duplicate that class in /debug and /release while keeping a single app class.
  3. You can opt for a no-op artifact that is used in release builds debugImplementation 'com....-no-op'

As far as I can tell from what I’ve read, it might be best to have a separate init class that I create myself as the no-op methods may still increase my method count? Not sure. Anyway, these are just my thoughts. I love flipper and would just love to make it the goto tool you include in any new app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Flipper to Android apps with Gradle
To set up Flipper for Android, you need to add the necessary dependencies to your app, initialize the Flipper client and enable the...
Read more >
Flipper implementation assambleRelease error - Stack Overflow
I am trying to assemble my app in Android ...
Read more >
Using Flipper with React Native - Parashuram's blog
In <your_rn_app>/android/app/build.gradle, inside dependencies section, add these lines for including Flipper in the project. Note that in the ...
Read more >
Installation | React Native Reanimated - Software Mansion
Please note that Reanimated 2 doesn't support remote debugging, only Flipper can be used for debugging. First step is to install react-native-reanimated alpha ......
Read more >
Debugging React Native apps with Flipper - LogRocket Blog
I spotted Flipper earlier when a project I was working on used an older version of React Native, but I didn't want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found