1

我正在使用 ANT 编译我构建的 Android 应用程序。这听起来很奇怪,可能没有什么区别,但我使用 Android SDK 构建了一个新项目,然后我使用 .NET 以编程方式修改项目中的几个文件,以便它按照我想要的方式构建。

我已经将项目加载到 Eclipse 中,它似乎可以正确编译,但是当我通过 ANT 运行它时,它无法正确编译。错误似乎说我有一个'?在项目的一项活动中。我多次确认,肯定没有“?” 在文件中。

错误:

 [javac] C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\src\com\infosol\SimpleTest\MyActivity.java:1: illegal character: \65279
        [javac] ?package com.infosol.SimpleTest;
        [javac] ^
        [javac] 1 error

如果有人对我做错了什么有想法,我将不胜感激。不确定什么会有所帮助,但以下是 ANT 输出的结果。

命令行:

C:\IBE_temp\java\bin\java -Dant.home="C:\IBE_temp\Packager\ANTSDK" -classpath "C:\IBE_temp\Packager\ANTSDK\lib\ant-launcher.jar" org.apache.tools .ant.launch.Launcher 发布 -v

部分 ANT 结果:

compile:
Property "tested.project.absolute.dir" has not been set
Property "tested.project.absolute.dir" has not been set
    [javac] C:\IBE_temp\Packager\AndroidSDK\tools\ant\main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=l
ast; set to false for repeatable builds
    [javac] com\infosol\SimpleTest\MyActivity.java added as com\infosol\SimpleTest\MyActivity.class doesn't exist.
    [javac] com\infosol\SimpleTest\R.java added as com\infosol\SimpleTest\R.class doesn't exist.
    [javac] Compiling 2 source files to C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\bin\classes
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-d'
    [javac] 'C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\bin\classes'
    [javac] '-classpath'
    [javac] 'C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\bin\classes;C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj;C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj
\libs\airbootstap.jar;C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\libs\xcelsiusLoad.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-launcher.jar;C:\IBE_temp\Pac
kager\ANTSDK\lib\ant-antlr.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-apache-bcel.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-apache-bsf.jar;C:\IBE_temp\Pack
ager\ANTSDK\lib\ant-apache-log4j.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-apache-oro.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-apache-regexp.jar;C:\IBE_t
emp\Packager\ANTSDK\lib\ant-apache-resolver.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-apache-xalan2.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-commons-logg
ing.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-commons-net.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-jai.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-javamail.j
ar;C:\IBE_temp\Packager\ANTSDK\lib\ant-jdepend.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-jmf.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-jsch.jar;C:\IBE_tem
p\Packager\ANTSDK\lib\ant-junit.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-junit4.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-netrexx.jar;C:\IBE_temp\Package
r\ANTSDK\lib\ant-swing.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant-testutil.jar;C:\IBE_temp\Packager\ANTSDK\lib\ant.jar;C:\IBE_temp\java\lib\tools.jar'
    [javac] '-sourcepath'
    [javac] 'C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\src;C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\gen'
    [javac] '-target'
    [javac] '1.5'
    [javac] '-bootclasspath'
    [javac] 'C:\IBE_temp\Packager\AndroidSDK\platforms\android-8\android.jar'
    [javac] '-encoding'
    [javac] 'UTF-8'
    [javac] '-g'
    [javac] '-source'
    [javac] '1.5'
    [javac]
    [javac] The ' characters around the executable and arguments are
    [javac] not part of the command.
    [javac] Files to be compiled:
    [javac]     C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\src\com\infosol\SimpleTest\MyActivity.java
    [javac]     C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\gen\com\infosol\SimpleTest\R.java
    [javac] C:\IBE_temp\_RTS\ANTTest\$SimpleTest\proj\src\com\infosol\SimpleTest\MyActivity.java:1: illegal character: \65279
    [javac] ?package com.infosol.SimpleTest;
    [javac] ^
    [javac] 1 error

BUILD FAILED
C:\IBE_temp\Packager\AndroidSDK\tools\ant\main_rules.xml:384: Compile failed; see the compiler error output for details.
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1150)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:809)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second
4

1 回答 1

7

我认为你正面临这个错误:http ://bugs.sun.com/view_bug.do?bug_id=4508058

尝试将您的文件编码更改为不带 BOM 的 UTF-8(请参阅)。

于 2011-08-26T05:25:56.140 回答