【问题标题】:Android Annotations not compiled with Ant未使用 Ant 编译的 Android 注释
【发布时间】:2012-07-27 04:35:46
【问题描述】:

按照here 列出的所有步骤后,我发现我的 (Class)_ 仍未生成。

自定义规则:

<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
<do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
    <!-- merge the project's own classpath and the tested project's classpath -->
    <path id="project.javac.classpath">
        <path refid="project.all.jars.path" />
        <path refid="tested.project.classpath" />
    </path>
    <javac encoding="${java.encoding}"
           source="${java.source}" target="${java.target}"
           debug="true" extdirs="" includeantruntime="false"
           destdir="${out.classes.absolute.dir}"
           bootclasspathref="project.target.class.path"
           verbose="${verbose}"
           classpathref="project.javac.classpath"
           fork="${need.javac.fork}">
        <classpath>
            <fileset dir="compile-libs" includes="*.jar"/>
        </classpath>
        <src path="${source.absolute.dir}" />
        <src path="${gen.absolute.dir}" />
        <compilerarg line="${java.compilerargs}" />
    </javac>
<!-- bunch of if conditions here -->
</target>
</project>

日志:

C:{path}{Class}.java (8:34) 找不到符号类 Activity_

注意:启动AndroidAnnotations注解处理

:“[dummy1343240015623]”类型的未关闭文件;这些类型不会进行注释处理

似乎处理开始之后它找不到Activity_。错误还是按预期?

所有文件都位于正确的位置(\libs 中的 api.jar,\compile-libs 中的 .jar),我终其一生都无法弄清楚。

已编辑:四处闲逛了一下。为 AndroidAnnotations 生成的源文件夹添加了新的property,在-compile 期间将其添加到javac src 路径中,但仍然没有运气。我第一次运行 ant 脚本时,它告诉我它找不到任何生成的类,第二次它告诉我它们都有重复(仍然给我unclsed files for types... 错误消息)。

【问题讨论】:

    标签: java android ant android-annotations


    【解决方案1】:

    所以,这里可能的解决方案。我需要为 javac 编译本身添加一些编辑,以及上面的 delete 和 mkdir,以便它会不断地重新生成它需要的所有文件,而不是由于覆盖权限而对自身产生错误。

    <target name="-compile"
            depends="-build-setup, -pre-build, -code-gen, -pre-compile">
        <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
            <!-- merge the project's own classpath and the tested project's classpath -->
            <path id="project.javac.classpath">
                <path refid="project.all.jars.path"/>
                <path refid="tested.project.classpath"/>
            </path>
    
            <delete dir="${out.aagen}"/>
    
            <mkdir dir="${out.aagen}"/>
            <javac encoding="${java.encoding}"
                   source="${java.source}"
                   target="${java.target}"
                   debug="true"
                   extdirs=""
                   includeantruntime="false"
                   destdir="${out.classes.absolute.dir}"
                   bootclasspathref="project.target.class.path"
                   verbose="${verbose}"
                   classpathref="project.javac.classpath"
                   fork="${need.javac.fork}">
                <src path="${source.absolute.dir}"/>
                <src path="${gen.absolute.dir}"/>
                <src path="${out.aagen}"/>
                <compilerarg line="${java.compilerargs}"/>
                <compilerarg line="-processorpath ${processorpath}"/>
                <compilerarg line="-processor ${processor}"/>
                <compilerarg line="-s ${out.aagen}"/>
            </javac>
        <!-- a bunch of other crap that is unimportant -->
    </target>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      • 2014-12-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-03
      • 2017-07-07
      相关资源
      最近更新 更多