[英]How to disable dex logging in Gradle Android?
Usually I turn on --info
to see proguardRelease
's output or to see why a certain task did or didn't execute. 通常,我打开
--info
来查看proguardRelease
的输出或查看为什么某个任务执行或未执行。
When I run assembleRelease
with --info
I get a huge spam from dexRelease
containing thousands of lines like: 当我用
--info
运行assembleRelease
,我从dexRelease
那里收到了大量垃圾邮件, dexRelease
包含数千行,例如:
processing archive I:\build\intermediates\classes-proguard\release\classes.jar...
processing android/support/v7/appcompat/R.class...
ignored resource META-INF/LICENSE.txt
processing android/support/v4/app/Fragment.class...
I think those lines should be --debug
level, but I don't know how to modify that. 我认为这些行应为
--debug
级,但我不知道如何修改。 I'd like to have all other output as usual, but ignore the spam from dexRelease
. 我希望像往常一样具有所有其他输出,但是忽略
dexRelease
的垃圾邮件。
I finally found a way to disable the dex output and just that (Android Gradle Plugin ~1.2): 我终于找到了一种禁用dex输出的方法,仅此而已(Android Gradle插件〜1.2):
import com.android.build.gradle.api.ApplicationVariant;
import com.android.builder.core.AndroidBuilder;
import java.lang.reflect.Field;
afterEvaluate {
project.android.applicationVariants.all { ApplicationVariant variant ->
if (!variant.dex) return;
Field v = AndroidBuilder.class.getDeclaredField("mVerboseExec")
v.accessible = true
boolean originalVerbose;
variant.dex.doFirst {
originalVerbose = v.get(variant.androidBuilder)
v.set(variant.androidBuilder, false)
}
variant.dex.doLast {
v.set(variant.androidBuilder, originalVerbose)
}
}
}
It's a little hacky (reflection), but I found no public API to do this becuase the mVerboseExec
value is initialized in the initialization phrase and the value is cached. 这有点怪癖(反思),但是我发现没有公共API可以执行此操作,因为
mVerboseExec
值已在初始化短语中进行了初始化,并且已缓存了该值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.