用Ant编译的Android项目无法编译,非法字符错误

时间:2011-08-26 05:20:19

标签: android ant illegal-characters

我正在使用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 release -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

1 个答案:

答案 0 :(得分:7)

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

尝试在没有BOM的情况下将文件编码更改为UTF-8(请参阅this)。