开发者

Android Project Compiled with Ant doesn't compile, Illegal Character Error

I am using ANT to compile an Android app that I have built. It sounds weird and probably doesn't make a difference, but I used the Android SDK to build a new project and then I used .NET to programatically modify a couple files within the project so it would build the way I wanted.

I have loaded the project into Eclipse, and it appears to compile properly, but when I run it through ANT, it doesn't compile properly. The error seems to say that I have a '?' in the one activity in the project. I have confirmed multiple times, there is definitely no '?' in the file.

Error:

 [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

If any one has thoughts on what I am doing wrong, I would really appreciate it. Not sure what will be helpful, but below are the results from the ANT output.

The command line:

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

Partial ANT Results:

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:2开发者_开发问答80)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second


I think you are facing this bug: http://bugs.sun.com/view_bug.do?bug_id=4508058

Try changing your file encoding to UTF-8 without BOM (see this).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜