gpt4 book ai didi

android - 导入库仅用于调试

转载 作者:行者123 更新时间:2023-11-29 00:03:33 25 4
gpt4 key购买 nike

我正在使用 stetho 库来调试我的应用程序。

Gradle :

debugCompile 'com.facebook.stetho:stetho:1.4.1'
debugCompile 'com.uphyca:stetho_realm:2.0.0'

应用类:

if (BuildConfig.DEBUG) {
Stetho.initialize(..);
}

但如果我需要创建一个发布版本,我必须每次都发表评论:

import com.facebook.stetho.Stetho; 
import com.uphyca.stetho_realm.RealmInspectorModulesProvider;

如何向编译器显示这些库仅用于调试?我们可以在不创建额外类的情况下使用注释或类似的东西对两行进行注释吗?

最佳答案

让未使用的导入保持原样。您的 if (BuildConfig.DEBUG) 方法完全有效。坦率地说,这是实现它的最佳方式。

未使用的导入对性能没有影响:reference .编译时间可能会略有增加,但运行时间不会增加。

Import statements don't make it to byte code.

你需要改变 Gradle :

debugCompile 'com.facebook.stetho:stetho:1.4.1'
debugCompile 'com.uphyca:stetho_realm:2.0.0'

compile 'com.facebook.stetho:stetho:1.4.1'
compile 'com.uphyca:stetho_realm:2.0.0'

关于android - 导入库仅用于调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45076313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com