Android studio編譯警告:請使用 -Xlint:deprecation 重新編譯

文章轉載下面地址:

https://blog.csdn.net/LB_fighting/article/details/53185410

Android studio編譯警告出現下面描述:

Note: Recompile with -Xlint:deprecation for details.

Note: Recompile with -Xlint:unchecked for details.

項目要求找出代碼裏面所有使用了Deprecation API的地方替換掉,按如下操作,便可以看到代碼那些地方使用了Deprection API:

只需要在build.gradle(Project:xxxxxxx)下找到allprojects標籤,加入:

gradle.projectsEvaluated {
     tasks.withType(JavaCompile) {
          options.compilerArgs << "-Xlint:unchecked" << "- Xlint:deprecation"
     }
}

因此allprojects標籤內容如下:
allprojects {
        repositories {
            jcenter()
        }
        gradle.projectsEvaluated {
             tasks.withType(JavaCompile) {
                   options.compilerArgs << “-Xlint:unchecked” << “-Xlint:deprecation”
              }
        }

}

可以在Android stuido的"Gradle Console"視圖中看到下面輸出:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章