感谢大家的帮助!
我在尝试使用Ant编译项目时遇到错误,它声称“[javac] javac:无效的目标版本:7”并导致构建失败 .
我在Mac OSX Mavericks机器上运行javac版本1.7.0_40 . Ant版本:Apache Ant(TM)版本1.8.3于2012年2月26日编译
只有在尝试使用Ant进行编译时才会出现问题 . 使用命令行中的javac编译项目中的单个文件(使用以下命令):
javac -d /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils -classpath /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils:/Users/username/git/appinventor-sources/appinventor/lib/guava/guava-14.0.1.jar -target 7 -encoding utf-8 -g:lines,vars,source -source 7 common/src/com/google/appinventor/common/utils/*
build-common.xml文件为javac指定:
阅读this后,我在我的机器上检查了早期的Java版本,但没有找到任何版本 .
executable="/usr/bin/javac"
到build-common.xml文件以确保它找到了正确的Java编译器,但错误仍在继续 .
命令行输出如下:
init:
CommonUtils:
[javac] Compiling 1 source file to /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils
[javac] javac: invalid target release: 7
[javac] Usage: javac
[javac] use -help for a list of possible options
BUILD FAILED
/Users/username/git/appinventor-sources/appinventor/build.xml:16: The following error occurred while executing this line:
/Users/username/git/appinventor-sources/appinventor/build-common.xml:318: The following error occurred while executing this line:
/Users/username/git/appinventor-sources/appinventor/common/build.xml:42: The following error occurred while executing this line:
/Users/username/git/appinventor-sources/appinventor/build-common.xml:120: Compile failed; see the compiler error output for details.
以详细方式运行ant产生了以下细节:
[javac] Compiling 1 source file to /Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils
[javac] Using modern compiler
[javac] Compilation arguments:
[javac] '-d'
[javac] '/Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils'
[javac] '-classpath'
[javac] '/Users/username/git/appinventor-sources/appinventor/common/build/classes/CommonUtils:/Users/username/git/appinventor-sources/appinventor/lib/guava/guava-14.0.1.jar'
[javac] '-target'
[javac] '7'
[javac] '-encoding'
[javac] 'utf-8'
[javac] '-g:lines,vars,source'
[javac] '-verbose'
[javac] '-source'
[javac] '7'
[javac]
[javac] The ' characters around the executable and arguments are
[javac] not part of the command.
[javac] File to be compiled:
[javac] /Users/username/git/appinventor-sources/appinventor/common/src/com/google/appinventor/common/utils/package-info.java
[javac] javac: invalid target release: 7
[javac] Usage: javac
[javac] use -help for a list of possible options
[ant] Exiting /Users/username/git/appinventor-sources/appinventor/common/build.xml.
有任何想法吗?非常感谢帮助 .