Android 源值 1.5 已过时,将在未来版本中删除

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24331705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:02:07  来源:igfitidea点击:

source value 1.5 is obsolete and will be removed in a future release

android

提问by Someone Somewhere

How do I prevent the two warnings below from generating an error that stops the build process ?

如何防止以下两个警告生成停止构建过程的错误?

-compile:
    [javac] Compiling 77 source files to /Users/andev/Workspace/android/products/myproject/1.0/Facebook/bin/classes
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    [javac] error: warnings found and -Werror specified
    [javac] 1 error
    [javac] 3 warnings

回答by matiash

Another possibility (which will fix it for allAndroid builds made with Ant), is to tweak the default parameters for the -compiletask in <android-sdk>\tools\ant\build.xml.

另一种可能性(将针对所有使用 Ant 构建的 Android 构建修复它)是-compile<android-sdk>\tools\ant\build.xml.

At the <!-- compilation options -->section, you can either set the compiler flags:

在该<!-- compilation options -->部分,您可以设置编译器标志:

<property name="java.compilerargs" value="-Xlint:-options" />

or, alternatively, change the source and target parameters:

或者,更改源和目​​标参数:

<property name="java.target" value="1.6" />
<property name="java.source" value="1.6" />

As of now, 1.6is enough to avoid the warning.

截至目前,1.6足以避免警告。

回答by Someone Somewhere

To be able to build, I created a file ant.propertiesin the facebook project (first project that is compiled) with the contents :

为了能够构建,我ant.properties在 facebook 项目(编译的第一个项目)中创建了一个文件,内容为:

java.compilerargs=-Xlint:-options

回答by Olaf Dietsche

This is set in the ${sdk.dir}/tools/ant/build.xmlfile. At the beginning of the file are many propertysettings, e.g.

这是在${sdk.dir}/tools/ant/build.xml文件中设置的。在文件的开头有很多property设置,例如

<!-- compilation options -->
<property name="java.encoding" value="UTF-8" />
<property name="java.target" value="1.5" />
<property name="java.source" value="1.5" />
<property name="java.compilerargs" value="" />
<property name="java.compiler.classpath" value="" />

Also at the beginning of this file is a comment

在这个文件的开头还有一条评论

At the beginning of the file is a list of properties that can be overridden
by adding them to your ant.properties (properties are immutable, so their
first definition sticks and is never changed).
At the beginning of the file is a list of properties that can be overridden
by adding them to your ant.properties (properties are immutable, so their
first definition sticks and is never changed).

So, in order to override any property in general and source value and target value in particular, you can put these properties into the ant.properties file in your project directory

因此,为了覆盖一般的任何属性,特别是源值和目标值,您可以将这些属性放入项目目录中的 ant.properties 文件中

java.source=1.6
java.target=1.6

This overrides the default settings in ${sdk.dir}/tools/ant/build.xmland thus prevents the warnings.

这会覆盖中的默认设置${sdk.dir}/tools/ant/build.xml,从而防止出现警告。