久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 gradle 編譯 android 庫時如何抑制警告?

How do I suppress warnings when compiling an android library with gradle?(使用 gradle 編譯 android 庫時如何抑制警告?)
本文介紹了使用 gradle 編譯 android 庫時如何抑制警告?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在我的應用程序中,我有一個由第 3 方開發的庫,不幸的是它包含很多 lint 和 javac 警告.我想忽略這兩種類型的警告,因為我們的團隊無法修復它們并且它們正在污染我們的構建日志.我嘗試將以下內容添加到庫 build.gradle 文件中:

In my application I have a library developed by a 3rd party that unfortunately contains quite a few lint and javac warnings. I'd like to ignore both these types of warnings since they can't be fixed by our team and they are polluting our build logs. I have tried adding the following to the libraries build.gradle file:

在 android 塊中

lintOptions {
    ignoreWarnings = true
}

我還在 build.gradle 文件的末尾添加了以下內容:

I also added the following to the end of the build.gradle file:

afterEvaluate {
    tasks.withType(JavaCompile) {
         it.options.compilerArgs << "-Xlint:none" << "-nowarn"
    }
}

不幸的是,每當 ":compileDebugJavaWithJavac" 運行時,它仍然會輸出該項目的警告.我做錯了什么?

Unfortunately, whenever ":compileDebugJavaWithJavac" runs, it still outputs the warnings from this project. What am I doing wrong?

編輯這是完整的 build.gradle 文件

EDIT Here is the build.gradle file in its entirety

apply plugin: 'com.android.library'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.2"

    lintOptions {
       abortOnError false        // true by default
       checkAllWarnings false
       checkReleaseBuilds false
       ignoreWarnings true       // false by default
       quiet true                // false by default
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

afterEvaluate {
    tasks.withType(JavaCompile) {
         it.options.compilerArgs << "-Xlint:none" << "-nowarn"
    }
}

以下是我想要消除的警告示例:

The following is an example of the warnings I am getting that I want to eliminate:

警告:[未選中] 對 isAssignableFrom(Class) 的未選中調用作為原始類型類的成員if (type.isAssignableFrom(throwables[i].getClass()))

warning: [unchecked] unchecked call to isAssignableFrom(Class) as a member of the raw type Class if (type.isAssignableFrom(throwables[i].getClass()))

推薦答案

Lint:

文檔:http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.LintOptions.html#com.android.build.gradle.internal.dsl.LintOptions:ignoreWarnings

android {
   lintOptions {
      abortOnError false        // true by default
      checkAllWarnings false
      checkReleaseBuilds false
      ignoreWarnings true       // false by default
      quiet true                // false by default
   }
}

Javac:

文檔:https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html

來自文檔,所有警告列表:

文檔:https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html#BHCJCABJ

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|[-]<group>)[/<access>] 
        Enable or disable specific checks for problems in javadoc comments,
        where <group> is one of accessibility, html, missing, reference, or syntax,
        and <access> is one of public, protected, package, or private.
  -Xbootclasspath/p:<path>   Prepend to the bootstrap class path
  -Xbootclasspath/a:<path>   Append to the bootstrap class path
  -Xbootclasspath:<path>     Override location of bootstrap class files
  -Djava.ext.dirs=<dirs>     Override location of installed extensions
  -Djava.endorsed.dirs=<dirs> Override location of endorsed standards path
  -Xmaxerrs <number>         Set the maximum number of errors to print
  -Xmaxwarns <number>        Set the maximum number of warnings to print
  -Xstdout <filename>        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'
}

這篇關于使用 gradle 編譯 android 庫時如何抑制警告?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當前風味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風味庫的多風味應用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 国产精品我不卡 | 国产亚韩| 欧美中文一区 | 五月天国产视频 | 日韩电影中文字幕 | 久久久高清 | 亚洲精品9999 | 久久精品亚洲精品国产欧美 | 九九热国产视频 | 狠狠久 | 国产精品亚洲视频 | 狠狠的操| 韩日av片| 中国黄色毛片视频 | 中文字幕在线免费 | 久久久青草婷婷精品综合日韩 | 一区二区在线 | 日韩一区二区三区在线 | 亚洲视频免费在线观看 | 一级毛片免费完整视频 | 亚洲色欲色欲www | 亚洲成人av | 久久久久久久久久久丰满 | 久久久久久女 | 91精品久久久久久久久中文字幕 | 日韩精品欧美精品 | 秋霞在线一区二区 | 午夜爽爽爽男女免费观看影院 | 国产午夜精品一区二区三区在线观看 | 一区二区三区在线观看视频 | 韩日一区二区三区 | 亚洲一区二区三区视频 | 中文字幕视频一区 | 精品久久久久久久久久久 | 91免费视频观看 | 午夜一区 | av官网在线 | 国产精品久久久久久久久久久久 | xx性欧美肥妇精品久久久久久 | 亚洲精品成人av久久 | 黄色毛片免费视频 |