2016-03-05 267 views

回答

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

,你可以把你的頂級的build.gradle:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.5.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 

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

或你的模塊之一:

apply plugin: 'com.android.application' 

android { 
    ... 
} 

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

tasks.withType(JavaCompile) { 
    options.compilerArgs << "-Xlint:deprecation" 
} 
+0

這是行不通的。 (似乎僅與java xlint警告相關) – AndreaF

+0

當我運行gradle任務'gradle app:build'時,我可以清楚地看到:警告:[已棄用] ***中的***()已被棄用 – Gut

+0

可以發佈完整你使用的build.gradle文件? – AndreaF