android如何实现编译警告,用gradle编译一个android库时,如何抑制警告?

皮棉:

android {

lintOptions {

abortOnError false // true by default

checkAllWarnings false

checkReleaseBuilds false

ignoreWarnings true // false by default

quiet true // false by default

}

}

javac的:

从文档中,列出所有警告:

Java版本:

$java -version

java version "1.8.0_102"

Java(TM) SE Runtime Environment (build 1.8.0_102-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

另外,警告选项:

$javac -X

-Xlint Enable recommended warnings

-Xlint:{all,auxiliaryclass,cast,classfile,deprecation,dep-ann,divzero,empty,fallthrough,finally,options,overloads,overrides,path,processing,rawtypes,serial,static,try,unchecked,varargs,-auxiliaryclass,-cast,-classfile,-deprecation,-dep-ann,-divzero,-empty,-fallthrough,-finally,-options,-overloads,-overrides,-path,-processing,-rawtypes,-serial,-static,-try,-unchecked,-varargs,none} Enable or disable specific warnings

-Xdoclint Enable recommended checks for problems in javadoc comments

-Xdoclint:(all|none|[-])[/]

Enable or disable specific checks for problems in javadoc comments,

where is one of accessibility, html, missing, reference, or syntax,

and is one of public, protected, package, or private.

-Xbootclasspath/p: Prepend to the bootstrap class path

-Xbootclasspath/a: Append to the bootstrap class path

-Xbootclasspath: Override location of bootstrap class files

-Djava.ext.dirs= Override location of installed extensions

-Djava.endorsed.dirs= Override location of endorsed standards path

-Xmaxerrs Set the maximum number of errors to print

-Xmaxwarns Set the maximum number of warnings to print

-Xstdout Redirect standard output

-Xprint Print out a textual representation of specified types

-XprintRounds Print information about rounds of annotation processing

-XprintProcessorInfo Print information about which annotations a processor is asked to process

-Xprefer:{source,newer} Specify which file to read when both a source file and class file are found for an implicitly compiled class

-Xpkginfo:{always,legacy,nonempty} Specify handling of package-info files

-Xplugin:"name args" Name and optional arguments for a plug-in to be run

-Xdiags:{compact,verbose} Select a diagnostic mode

These options are non-standard and subject to change without notice.

关闭所有警告:

// Put this in 'root' `build.gradle`, in allprojects or subprojects

tasks.withType(JavaCompile) {

// Try to turn them all off automatically

options.compilerArgs << '-Xlint:none'

options.compilerArgs << '-nowarn' // same as '-Xlint:none'

// Turn them off manually

options.compilerArgs << '-Xlint:-auxiliaryclass'

options.compilerArgs << '-Xlint:-cast'

options.compilerArgs << '-Xlint:-classfile'

options.compilerArgs << '-Xlint:-deprecation'

options.compilerArgs << '-Xlint:-dep-ann'

options.compilerArgs << '-Xlint:-divzero'

options.compilerArgs << '-Xlint:-empty'

options.compilerArgs << '-Xlint:-fallthrough'

options.compilerArgs << '-Xlint:-finally'

options.compilerArgs << '-Xlint:-options'

options.compilerArgs << '-Xlint:-overloads'

options.compilerArgs << '-Xlint:-overrides'

options.compilerArgs << '-Xlint:-path'

options.compilerArgs << '-Xlint:-processing'

options.compilerArgs << '-Xlint:-rawtypes'

options.compilerArgs << '-Xlint:-serial'

options.compilerArgs << '-Xlint:-static'

options.compilerArgs << '-Xlint:-try'

options.compilerArgs << '-Xlint:-unchecked'

options.compilerArgs << '-Xlint:-varargs'

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值