菜鸟提问:linux 下面使用ant构建apk失败
linux下对apk使用ant 构建时,在import时提示失败,从错误信息来看,应该是相关包没有导入,但是在build文件中也尝试引入jar包,但还是报错,请各位大侠指点下。
详细错误信息如下:
[javac] /home/xx/android/platform/packages/ss/product/application/settings/src/com/android/settings/AutoStandbyFragment.java:23: cannot find symbol
[javac] symbol: class Fragment
[javac] public class AutoStandbyFragment extends Fragment implements OnKeyListener {
[javac] ^
[javac] /home/xx/android/platform/packages/ss/product/application/settings/src/com/android/settings/AutoStandbyFragment.java:23: cannot find symbol
[javac] symbol: class OnKeyListener
[javac] public class AutoStandbyFragment extends Fragment implements OnKeyListener {
[javac] ^
[javac]/home/xx/android/platform/packages/ss/product/application/settings/src/com/android/settings/AutoStandbyFragment.java:26: cannot find symbol
[javac] symbol : class EditText
[javac] location: class com.android.settings.AutoStandbyFragment
[javac] private EditText mStandbyTimeEdit;
[javac] ^
[javac]/home/xx/android/platform/packages/ss/product/application/settings/src/com/android/settings/AutoStandbyFragment.java:27: cannot find symbol
[javac] symbol : class Button
[javac] location: class com.android.settings.AutoStandbyFragment
[javac] private Button mStandbyTimeButton;
[javac] ^
[javac] /home/xx/android/platform/packages/ss/product/application/settings/src/com/android/settings
[javac] symbol : class McspCompCommun
[javac] location: class com.android.settings.AutoStandbyFragment
[javac] private static McspCompCommun compCom = null;
[javac] ^
[javac] /home/xx/android/platform/packages/ss/product/application/settings/src/com/android/settings
[javac] symbol : class McspCfgmanager
build.xml文件配置如下:
<?xml version="1.0"?>
<project name="newSettings" basedir="." default="all">
<!--You may notice that, I use location instead of value -->
<!--Both of them work correctly when I run ant -f build.xml -->
<!--But when this file is called by other ant file using ant task-->
<!--In the junit task, the relative path cannot be parsed correctly-->
<!--When using location, the path will be replaced with absolute path-->
<!--The libs contains the emma.jar and emma_ant.jar-->
<property name="libs" location="../lib" />
<!--This is where we place our instrumented classes-->
<property name="bin.instrument.dir" location="../instrbin" />
<!--coverage metadata and report location-->
<property name="coverage.dir" location="../coverage" />
<!--junit report location-->
<property name="junitReport.dir" location="../junitReport" />
<!--main bin location-->
<property name="bin.main.dir" location="../srcbin" />
<!--test bin location-->
<property name="bin.test.dir" location="../testbin" />
<!--main source location-->
<property name="src.main.dir" location="./src" />
<!--test source location-->
<property name="src.test.dir" location="./test" />
<!--Instrument classes in this path-->
<path id="classpath.main">
<pathelement location="${bin.main.dir}" />
</path>
<!--Path where emma.jar and emma_ant.jar exist-->
<path id="emma.lib">
<pathelement location="${libs}/emma.jar" />
<pathelement location="${libs}/emma_ant.jar" />
</path>
<!--enable emma-->
<property name="emma.enabled" value="true" />
<!--Add emma task to ant-->
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<!--Default task-->
<target name="all" depends="clean,compile-src.main,compile-src.test,
instrument,test,gen-report-junit,gen-report-coverage">
</target>
<property name="lib.dir" value="/home/xx/android/platform/out/target/product/sdk/dex_bootjars/system/framework"/>
<path id="compile.classpath">
<fileset dir="${lib.dir}" includes="./*.jar"/>
</path>
<target name="compile-src.main">
<mkdir dir="${bin.main.dir}" />
<javac destdir="${bin.main.dir}" debug="on">
<src path="${src.main.dir}" />
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${bin.main.dir}">
<fileset dir="${src.main.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="compile-src.test">
<mkdir dir="${bin.test.dir}" />
<javac destdir="${bin.test.dir}" debug="on">
<src path="${src.test.dir}" />
<classpath location="${bin.main.dir}" />
</javac>
<copy todir="${bin.test.dir}">
<fileset dir="${src.test.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<!--Instrument the src main bin, place the instrumented class in bin.instrument.dir-->
<!--metadata file will be placed in coverage.dir-->
<target name="instrument">
<mkdir dir="${bin.instrument.dir}" />
<mkdir dir="${coverage.dir}" />
<emma enabled="${emma.enabled}">
<instr instrpathref="classpath.main" destdir="${bin.instrument.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true">
</instr>
</emma>
<copy todir="${bin.instrument.dir}">
<fileset dir="${bin.main.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<!--Run test case, generate junit report and coverage report-->
<target name="test">
<mkdir dir="${junitReport.dir}" />
<junit fork="true" forkmode="once" printsummary="withOutAndErr" errorproperty="test.error" showoutput="on">
<!--Refer to metadata.emma to collect run information-->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/metadata.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<!--Test support package-->
<classpath location="${bin.instrument.dir}" />
<classpath location="${bin.test.dir}" />
<classpath refid="emma.lib" />
<formatter type="xml" />
<!--Batch test exclude inner class-->
<batchtest todir="${junitReport.dir}" haltonfailure="no">
<fileset dir="${bin.test.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="gen-report-junit">
<!--Generate junit report-->
<junitreport todir="${junitReport.dir}">
<fileset dir="${junitReport.dir}">
<include name="*" />
</fileset>
<report format="frames" todir="${junitReport.dir}" />
</junitreport>
</target>
<!--Generate the coverage report-->
<target name="gen-report-coverage">
<!-- if enabled, generate coverage report(s): -->
<emma enabled="${emma.enabled}">
<report sourcepath="${src.main.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100">
<fileset dir="${coverage.dir}">
<include name="*.emma" />
</fileset>
<html outfile="${coverage.dir}/coverage.html" depth="method" columns="name,class,method,block,line" />
</report>
</emma>
</target>
<!--Clean srcbin, instrumented bin,junit report, coverage report-->
<target name="clean">
<delete dir="${bin.instrument.dir}" />
<delete dir="${coverage.dir}" />
<delete dir="${junitReport.dir}" />
<delete dir="${bin.main.dir}" />
<delete dir="${bin.test.dir}" />
</target>
</project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
跪谢答复! 但是还有问题,看了我们的工程,android/platform下有sdk目录,但是没有folder目录,也没搜索到android.sh,是不是编译服务器没有安装sdk,但是为什么又可以编译工程呢?
回复
http://developer.android.com/tools/projects/projects-cmdline.html
为什么自己写build.xml?
$android/sdk/folder/android.sh -update-project path/to/project
这个会帮你生成build.xml
你可以先去看看sdk tools文档