我应该删除泄漏金丝雀代码/类以进行发布构建吗?

see*_*ess 5 android memory-leaks release leakcanary

我搜索了一个答案,找不到任何东西,这可能意味着这是一个基本问题.冒着表达我无知的风险,无论如何我都会问.我正在准备我的应用程序发布,并希望确保泄漏金丝雀不会弹出我的用户.我的泄漏金丝雀相关的依赖关系就是这样.

dependencies {
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
}
Run Code Online (Sandbox Code Playgroud)

我认为,因为releaseCompile包含no-op它意味着我可以按原样继续我的发布版本而不删除Leak Canary代码.我对吗?

see*_*ess 14

我在网上发现了这个.

dependencies {
// Real LeakCanary for debug builds only: notifications, analysis, etc
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'

// No-Op version of LeakCanary for release builds: no notifications, no analysis, nothing
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
Run Code Online (Sandbox Code Playgroud)

  • 为什么添加no-op如果什么都不做? (4认同)
  • @farhanpatel因为即使它什么都不做,你仍然需要有类来编译你的应用程序 (3认同)

sud*_*der 5

答案是正确的,但截至 2019 年 4 月 13 日有一个更新且更简单的解决方案:

    dependencies {
      debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
    }
Run Code Online (Sandbox Code Playgroud)

不需要 no-ops 或 proguard。

为什么?

好的,但是怎么样?