请使用-Xlint:deprecation重新编译

【已解决】Android Studio编译OsmAnd出现警告:GeoPointParserUtil.java使用或覆盖了已过时的 API。有关详细信息请使用-Xlint:deprecation重新编译

【背景】

之前折腾:

【记录】Android Studio中导入OsmAnd并编译

期间,遇到了编译警告:

1
2
3
4
5
:OsmAnd-java:compileJava
注: E:\crifan\DevRoot\Osmand-master\OsmAnd-java\src\net\osmand\util\GeoPointParserUtil.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

如图:

id="iframe_0.15554649902404516" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i0.wp.com/www.crifan.com/files/pic/uploads/2015/04/android-studio-build-osmand-warning-use-deprecated-api_thumb.png?resize=615%252C265&_=5665842%22%20style=%22border:none;max-width:1104px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.15554649902404516',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 615px; height: 265px;">

【解决过程】

1.之前不知道如何解决。然后也没影响继续编译,所以当时就没理会。

2.后来看到:

Android Studio系列教程四–Gradle基础

中的:

1
2
3
4
// 移除lint检查的error
lintOptions {
   abortOnError false
}

猜测是,build.gradle中有对应的此处,可以添加lint的参数,估计上面说的:

1
2
-Xlint:deprecation
-Xlint:unchecked

 

的参数,或许可以放在这里。

所以去尝试一下。

但是在Osmand-java中的build.gradle中并没有看到那个(android下的)lintOptions

id="iframe_0.324077392384748" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i2.wp.com/www.crifan.com/files/pic/uploads/2015/04/not-see-lintoption-in-build.gradle-of-osmand-java_thumb.png?resize=615%252C558&_=5665842%22%20style=%22border:none;max-width:1104px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.324077392384748',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 615px; height: 558px;">

 

所以,还是去网上搜索这个问题吧。

3.搜:

android studio Xlint:deprecation

参考:

How to add -Xlint:unchecked to my Android Gradle based project? – Stack Overflow

去加上这个配置:

id="iframe_0.7368314952187547" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i0.wp.com/www.crifan.com/files/pic/uploads/2015/04/build.gradle-added-allproject-xlint-deprecation_thumb.png?resize=615%252C491&_=5665842%22%20style=%22border:none;max-width:1104px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7368314952187547',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 615px; height: 491px;">

然后再去编译看看。

果然没了警告了:

id="iframe_0.8632977564334054" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://i1.wp.com/www.crifan.com/files/pic/uploads/2015/04/now-osmand-java-compilejava-up-to-date-ok_thumb.png?resize=615%252C303&_=5665842%22%20style=%22border:none;max-width:1104px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8632977564334054',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="border-width: initial; border-style: none; width: 615px; height: 303px;">

 

【总结】

当Android Studio中编译java方面的代码,出现类似的警告:

  • 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
  • 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

时,去项目对应的build.gradle中添加配置:

1
2
3
4
5
6
7
allprojects {
     gradle.projectsEvaluated {
         tasks.withType(JavaCompile) {
             options.compilerArgs << "-Xlint:unchecked"  << "-Xlint:deprecation"
         }
     }
}

即可消除警告。

 
分类:  Java
标签:  转载自http://www.crifan.com/android_studio_build

你可能感兴趣的:(请使用-Xlint:deprecation重新编译)