日期:2014-05-20  浏览次数:20562 次

用apache的ant.jar在安卓上解zip压缩,pc运行没问题,但安卓上就报错,请帮忙!
PC运行正常,安卓运行就报错,请各位帮忙。
源码:
public static void unzip2(String sourceZip,String destDir) throws Exception{  
  try{  
  Project p = new Project();  
  Expand e = new Expand();  
  e.setProject(p);  
  e.setSrc(new File(sourceZip));  
  e.setOverwrite(false);  
  e.setDest(new File(destDir));  
  e.setEncoding("UTF-8"); //根据linux系统的实际编码设置
  e.execute();  
  }catch(Exception e){  
  throw e;  
  }
  }  

  报错如下:

GC freed 640 objects / 50336 bytes in 38ms
Could not find class 'org.apache.tools.ant.Project', referenced from method cn.cmmb.zip2.Decompression.unzip2
VFY: unable to resolve new-instance 93 (Lorg/apache/tools/ant/Project;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x0000
Making a copy of Lcn/cmmb/zip2/Decompression;.unzip2 code (116 bytes)
VFY: unable to find class referenced in signature (Lorg/apache/tools/zip/ZipOutputStream;)
Could not find class 'org.apache.tools.zip.ZipEntry', referenced from method cn.cmmb.zip2.Decompression.zip
VFY: unable to resolve new-instance 95 (Lorg/apache/tools/zip/ZipEntry;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x000b
Making a copy of Lcn/cmmb/zip2/Decompression;.zip code (425 bytes)
Could not find class 'org.apache.tools.zip.ZipEntry', referenced from method cn.cmmb.zip2.Decompression.zip
VFY: unable to resolve new-instance 95 (Lorg/apache/tools/zip/ZipEntry;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x006d
Could not find class 'org.apache.tools.zip.ZipEntry', referenced from method cn.cmmb.zip2.Decompression.zip
VFY: unable to resolve new-instance 95 (Lorg/apache/tools/zip/ZipEntry;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x008c
Could not find class 'org.apache.tools.zip.ZipFile', referenced from method cn.cmmb.zip2.Decompression.unzip
VFY: unable to resolve new-instance 96 (Lorg/apache/tools/zip/ZipFile;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x0014
Making a copy of Lcn/cmmb/zip2/Decompression;.unzip code (635 bytes)
Could not find class 'org.apache.tools.zip.ZipFile', referenced from method cn.cmmb.zip2.Decompression.unzip
VFY: unable to resolve new-instance 96 (Lorg/apache/tools/zip/ZipFile;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x0014
Making a copy of Lcn/cmmb/zip2/Decompression;.unzip code (635 bytes)
Could not find class 'org.apache.tools.zip.ZipOutputStream', referenced from method cn.cmmb.zip2.Decompression.zip
VFY: unable to resolve new-instance 97 (Lorg/apache/tools/zip/ZipOutputStream;) in Lcn/cmmb/zip2/Decompression;
VFY: replacing opcode 0x22 at 0x0001
Making a copy of Lcn/cmmb/zip2/Decompression;.zip code (137 bytes)
Shutting down VM

------解决方案--------------------
classPath上缺少apache tools的jar包
------解决方案--------------------
在你的PC上能找到这个Jar包。到了安卓上就找不到这个目录了,换个PC也跑不了了。换成相对路径
探讨

有的 <classpathentry kind="lib" path="E:/Workspaces/CMMBProject/lib/ant-1.7.1.jar"/>