You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flipper Network Plugin无网络请求显示问题排查求助

Fix for Flipper Not Showing Network Traffic

Hey there, I spot the exact issue causing your Flipper network traffic not to show up!

The core problem is that you're creating two separate instances of NetworkFlipperPlugin: one in your MoveeApp's initFlipper() method (which gets added to the Flipper client) and another brand new one in your NetworkModule (which gets passed to the OkHttp interceptor). These two instances don't share any state, so the requests intercepted by OkHttp never reach the Flipper client you set up.

Here's how to fix it:

  1. Store the NetworkFlipperPlugin instance in your Application class
    Make the plugin instance accessible globally so your NetworkModule can reuse it instead of creating a new one:

    class MoveeApp : Application() {
        // Lazy initialize the plugin to avoid unnecessary creation in release builds
        val networkFlipperPlugin by lazy { NetworkFlipperPlugin() }
    
        override fun onCreate() {
            super.onCreate()
            initFlipper()
        }
    
        private fun initFlipper() {
            SoLoader.init(this, false)
            if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
                val flipperClient = AndroidFlipperClient.getInstance(this)
                flipperClient.addPlugin(
                    InspectorFlipperPlugin(
                        this@MoveeApp,
                        DescriptorMapping.withDefaults()
                    )
                )
                // Add the same plugin instance to Flipper client
                flipperClient.addPlugin(networkFlipperPlugin)
                flipperClient.start()
            }
        }
    }
    
  2. Reuse the existing plugin instance in NetworkModule
    Inject your Application into the module, then fetch the pre-created plugin instead of instantiating a new one:

    @InstallIn(ApplicationComponent::class)
    @Module
    object NetworkModule {
        @Singleton
        @Provides
        fun provideOkHttpClient(
            requestInterceptor: RequestInterceptor,
            application: Application // Inject the Application context
        ): OkHttpClient =
            OkHttpClient.Builder()
                .addInterceptor(requestInterceptor)
                // Use the plugin instance from MoveeApp
                .addNetworkInterceptor(FlipperOkhttpInterceptor((application as MoveeApp).networkFlipperPlugin))
                .build()
    }
    

Quick checks to ensure everything works:

  • Restart your Android app and the Flipper desktop client (sometimes a fresh connection is needed)
  • Double-check that the Network plugin is enabled in your Flipper desktop app
  • Confirm all your Flipper dependencies (mobile + desktop) are on the same version (you're already using 0.54.0 across the board, which is good!)

After making these changes, your OkHttp requests should be intercepted and passed to the Flipper client's Network plugin, and you'll start seeing the traffic in the desktop app.

内容的提问来源于stack exchange,提问作者Şevval

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 23:32:56