'Flipper Network Plugin doesn't show network requests
According to the documents here, I followed the necessary steps. Yet, even though I can see the requested data when I debug my app, I see no network traffic on Flipper. Here is my code:
Dependencies:
debugImplementation 'com.facebook.flipper:flipper:0.54.0'
debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.54.0'
debugImplementation 'com.facebook.soloader:soloader:0.9.0'
Application Setup:
class MoveeApp : Application() {
override fun onCreate() {
super.onCreate()
initFlipper()
}
private fun initFlipper() {
SoLoader.init(this, false)
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
val flipperClient = AndroidFlipperClient.getInstance(this)
val networkFlipperPlugin = NetworkFlipperPlugin()
flipperClient.addPlugin(
InspectorFlipperPlugin(
this@MoveeApp,
DescriptorMapping.withDefaults()
)
)
flipperClient.addPlugin(networkFlipperPlugin)
flipperClient.start()
}
}
}
Network Module where I provide OkHttpClient:
The document says here "As interceptors can modify the request and response, add the Flipper interceptor after all others to get an accurate view of the network traffic.". That's why I added network interceptor after I added the request interceptor, as can be seen below.
@InstallIn(ApplicationComponent::class)
@Module
object NetworkModule {
@Singleton
@Provides
fun provideOkHttpClient(requestInterceptor: RequestInterceptor): OkHttpClient =
OkHttpClient.Builder()
.addInterceptor(requestInterceptor)
.addNetworkInterceptor(FlipperOkhttpInterceptor(NetworkFlipperPlugin()))
.build()
}
The desktop app's version is "0.54.0" as well and Network plugin is enabled.
Is there something I fail to notice?
Solution 1:[1]
In function provideOkHttpClient
the code is creating a new instance of NetworkFlipperPlugin
that is not registered with the flipper client.
In MoveeApp
the code is also creating a NetworkFlipperPlugin
that is coupled to the flipper client, but that plugin is not registered as an interceptor.
Expose the flipper network plugin in MoveeApp and retrieve it, something like:
.addNetworkInterceptor(FlipperOkhttpInterceptor(MoveeApp.flipperNetworkPlugin))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AndroidGuy |