问题描述
各位大神好,最近本人在开发完j2me手机应用项目后,打包使用的是ant,打包后的jar中MANIFEST.MF里中文为乱码,经本人数日苦思研究并查阅资料后无果,甚至苦恼;鄙人愚钝,特在此请教各位大神指点一二,望各位不惜赐教,静候贵帖!以下是build.xml内容:<?xmlversion="1.0"encoding="UTF-8"?><projectname="${programName}"default="end"basedir="."><propertyname="flag.value"value=""/><propertyfile="CONF.properties"/><propertyname="src.dir"value="${basedir}src"/><propertyname="res.dir"value="${basedir}res"/><propertyname="build.dir"value="${basedir}build"/><propertyname="deploy.dir"value="${basedir}deploy"/><propertyname="package.dir"value="${basedir}package"/><propertyname="package.extract.dir"value="${package.dir}extract"/><propertyname="preverified.dir"value="${basedir}preverified"/><propertyname="preverified.noObfusedClass.dir"value="${preverified.dir}noObfusedclasses"/><propertyname="preverified.obfusedClass.dir"value="${preverified.dir}obfusedclasses"/><propertyname="preverify.bin"value="${wtk.home.dir}binpreverify.exe"/><propertyname="emulator.bin"value="${wtk.home.dir}binemulator.exe"/><propertyname="jad.file"value="${programName}.jad"/><propertyname="debuglevel"value="source,vars"/><propertyname="target"value="1.1"/><propertyname="source"value="1.3"/><targetname="replaceJava"><echomessage="替换文件,修改渠道号"/><deletefile="E:metreworkspacekjavaSIPDemosrccomfeedovmainNet.java"/><copyfile="E:metreworkspacekjavaSIPDemoNet.java"todir="E:metreworkspacekjavaSIPDemosrccomfeedovmain"/><replacefile="E:metreworkspacekjavaSIPDemosrccomfeedovmainNet.java"token="100000"value="${flag.value}"encoding="UTF-8"/></target><targetname="init"description="初始化环境"><echomessage="初始化目录"/><mkdirdir="${build.dir}"/><mkdirdir="${deploy.dir}"/><mkdirdir="${package.dir}"/><mkdirdir="${package.extract.dir}"/><mkdirdir="${preverified.dir}"/><mkdirdir="${preverified.noObfusedClass.dir}"/><mkdirdir="${preverified.obfusedClass.dir}"/></target><targetname="compile"depends="init"description="编译"><echomessage="编译程序"/><!--<javacdebug="on"bootclasspath="${midp.lib.path}"classpath="${midp.lib.path};."srcdir="${src.dir}"destdir="${build.dir}"/>--><javacdebug="true"debuglevel="${debuglevel}"srcdir="${src.dir}"destdir="${build.dir}"source="${source}"target="${target}"encoding="UTF-8"><bootclasspathpath="${midp.lib.path}"/><classpath><filesetdir="${midp.lib.dir}"includes="*.jar"/></classpath></javac></target><targetname="clean"><echomessage="删除目录"/><deletedir="${build.dir}"/><deletedir="${deploy.dir}"/><deletedir="${package.dir}"/><deletedir="${preverified.dir}"/></target><targetname="verifyForNoObfuscate"description="验证j2me的class,将验证后的class输出到${preverified.noObfusedClass.dir}"><echomessage="验证生成的class,将验证后的class输出到${preverified.noObfusedClass.dir}"/><execexecutable="${preverify.bin}"searchpath="false"><argline="-classpath${midp.lib.path}"/><argline="-d${preverified.noObfusedClass.dir}"/><argline="${build.dir}"/></exec></target><targetname="genManifest"description="根据模板属性文件的值生成Manifest文件"><echomessage="根据模板属性文件的值生成Manifest文件"/><!--使用${programName}替换掉属性文件GEN.properties中的@PROGRAMNAME@--><replacefile="GEN.properties"token="@PROGRAMNAME@"value="${programName}"/><!--使用GEN.properties文件中的属性值替换掉模板文件MANIFEST.tmp中的对应属性值,将替换后的数据复制到${src.dir}MANIFEST.MF--><copyfile="MANIFEST.MF"tofile="${src.dir}MANIFEST.MF"><filtersetbegintoken="@"endtoken="@"><filtersfilefile="GEN.properties"/></filterset></copy></target><targetname="package"description="将class打包,输出到${package.dir}"><echomessage="将class打包,输出到${package.dir}"/><jarbasedir="${preverified.noObfusedClass.dir}"jarfile="${package.dir}${programName}-noObfused.jar"manifest="${src.dir}MANIFEST.MF"encoding="UTF-8"><filesetdir="${res.dir}"includes="**/*.png"/></jar></target><targetname="obfuscate"description="对打包后的jar文件进行混淆,然后解压缩至${package.extract.dir}"><echomessage="对打包后的jar文件进行混淆,然后解压缩至${package.extract.dir}"/><javafork="true"classname="proguard.ProGuard"><classpathpath="${proguard.lib.dir}proguard.jar"/><argline="-libraryjars${midp.lib.path}"/><argline="-injar${package.dir}${programName}-noObfused.jar"/><argline="-outjar${package.dir}${programName}-obfused.jar"/><!--保留MIDlet的类声明不被混淆--><argline="-keep'publicclass*extendsjavax.microedition.midlet.MIDlet'"/><!--打印被保留的类名--><argline="-printseeds"/></java><unjarsrc="${package.dir}${programName}-obfused.jar"dest="${package.extract.dir}"/></target><targetname="verifyForObfuscate"description="验证被混淆的class,输出到${preverified.obfusedClass.dir}"><echomessage="验证被混淆的class,输出到${preverified.obfusedClass.dir}"/><execexecutable="${preverify.bin}"searchpath="false"><argline="-classpath${midp.lib.path}"/><argline="-d${preverified.obfusedClass.dir}"/><argline="${package.extract.dir}"/></exec><copytodir="${preverified.obfusedClass.dir}"><filesetdir="${package.extract.dir}"includes="**/*.png"/></copy></target><targetname="deploy"description="将经过验证的混淆后的class打包,部署在delpoy目录"><echomessage="将经过验证的混淆后的class打包,部署在${deploy.dir}目录"/><jarbasedir="${preverified.obfusedClass.dir}"encoding="UTF-8"jarfile="${deploy.dir}${programName}${flag.value}.jar"manifest="${src.dir}MANIFEST.MF"><filesetdir="${preverified.obfusedClass.dir}"includes="**/*.class;*.png"/></jar></target><targetname="genJad"description="在${deploy.dir}目录生成JAD文件"><echomessage="在${deploy.dir}目录生成JAD文件"/><lengthfile="${deploy.dir}${programName}.jar"property="jarsize"/><echomessage="获得jar文件长度:${jarsize}"/><replacefile="GEN.properties"token="@JARSIZE@"value="${jarsize}"/><replacefile="GEN.properties"token="@PROGRAMNAME@"value="${programName}"/><copyfile="JAD.mod"tofile="${deploy.dir}${programName}${flag.value}.jad"><filtersetbegintoken="@"endtoken="@"><filtersfilefile="GEN.properties"/></filterset></copy></target><targetname="recoveryGenProperties"description="恢复被修改的GEN.properties"><echomessage="恢复被修改的GEN.properties"/><replacefile="GEN.properties"token="MIDLET_NAME=${programName}"value="MIDLET_NAME=@PROGRAMNAME@"/><replacefile="GEN.properties"token="MIDLET_JAR_URL=${programName}.jar"value="MIDLET_JAR_URL=@PROGRAMNAME@.jar"/><replacefile="GEN.properties"token="MIDLET_JAR_SIZE=${jarsize}"value="MIDLET_JAR_SIZE=@JARSIZE@"/></target><targetname="end"depends="replaceJava,compile,verifyForNoObfuscate,genManifest,package,obfuscate,verifyForObfuscate,deploy,genJad,recoveryGenProperties"/></project>
解决方案
解决方案二:
楼主问题解决没有?我用ant批量打包android也出现manifest.xml乱码