我开发了一个j2me应用程序,它工作正常。
在我的应用程序中,我有build.xml,当我运行这个build.xml时,会生成一个jar和jad文件。
但是这里构建失败但是jar和jad被创建了,当我运行jad时,应用程序没有运行。
请帮我看看如何在j2me中编写build.xml,以下是我的build.xml
<project name="DEMO" default="build" basedir=".">
<!-- set global properties for this build -->
<taskdef resource="antenna.properties" classpath="../antenna/antenna-bin-1.2.1-beta.jar" />
<property name="lib" location="../lib" />
<property name="program_name" value="DEMO" />
<property name="package_name" value="DEMO" />
<property name="midp_home" value="C:/WTK2.5.2_01" />
<property name="wtk.home" value="C:/WTK2.5.2_01" />
<property name="wtk.midp.version" value="2.0" />
<property name="wtk.cldc.version" value="1.1" />
<path id="lib.path">
<fileset dir="${lib}">
<include name="LWUIT.jar"/>
</fileset>
</path>
<property name="src" value="src" />
<property name="res" value="res" />
<property name="build" value="build" />
<property name="dist" value="dist" />
<!--Create the build directory structure used by compile and dist-->
<target name="init">
<delete dir="${build}" />
<delete dir="${dist}" />
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<mkdir dir="${build}/classes" />
</target>
<!-- Compile Source -->
<target name="compile" depends="init">
<wtkbuild srcdir="src" destdir="${build}/classes" preverify="false">
<classpath refid="lib.path"/>
</wtkbuild>
<unjar src="../lib/LWUIT.jar" dest="${build}/classes" />
</target>
<!-- Creat build and Preverify -->
<target name="package" depends="compile" >
<wtkjad jadfile="${dist}\${program_name}.jad" manifest="${dist}/MANIFEST.MF"
jarfile="${dist}\${program_name}.jar" name="DEMO"
vendor="xyz" version="1.2">
<midlet name="DEMO" icon="/i.png" class="MM" />
<attribute name="endpoint"
value="http://localhost/j2meservice" />
<attribute name="MicroEdition-Configuration" value="CLDC-1.1"/>
<attribute name="MicroEdition-Profile" value=" MIDP-2.0"/>
<attribute name="MIDlet-Description" value=" Smart Phones"/>
<attribute name="devicetype" value="bb" />
</wtkjad>
<wtkpackage jarfile="${dist}/${program_name}.jar"
jadfile="${dist}/${program_name}.jad" obfuscate="false"
preverify="false">
<fileset dir="${build}/classes" includes="**/*.class" />
<fileset dir="${res}" includes="**" />
</wtkpackage>
</target>
<target name="obfuscate" depends="package">
<wtkobfuscate jarfile="${dist}/${program_name}.jar"
jadfile="${dist}/${program_name}.jad" obfuscator="proguard" >
<argument value="-defaultpackage"/>
<argument value="-repackageclasses"/>
</wtkobfuscate>
</target>
<target name="preverify" depends="obfuscate">
<wtkpreverify jarfile="${dist}/${program_name}.jar" jadfile="${dist}/${program_name}.jad" >
</wtkpreverify>
</target>
<target name="build" depends="preverify">
</target>
<target name="run">
<exec executable="${midp_home}/bin/emulator">
<arg line="-Xdescriptor:${dist}/${program_name}.jad" />
</exec>
</target>
</project>
这是我的build.xml的输出
Buildfile: D:\eclipse-pulsar-copy-workspace\DEMO\build.xml
init:
[delete] Deleting directory D:\eclipse-pulsar-copy-workspace\DEMO\build
[delete] Deleting directory D:\eclipse-pulsar-copy-workspace\DEMO\dist
[mkdir] Created dir: D:\eclipse-pulsar-copy-workspace\DEMO\build
[mkdir] Created dir: D:\eclipse-pulsar-copy-workspace\DEMO\dist
[mkdir] Created dir: D:\eclipse-pulsar-copy-workspace\DEMO\build\classes
compile:
[wtkbuild] **************************************************************
[wtkbuild] * Antenna 1.2.1 initialized for project "DEMO" *
[wtkbuild] * Using "Sun Wireless Toolkit 2.5" (CLDC-1.1; MIDP-2.0) *
[wtkbuild] **************************************************************
[wtkbuild] Compiling 705 source files to D:\eclipse-pulsar-copy-workspace\DEMO\build\classes
[wtkbuild] Note: Some input files use or override a deprecated API.
[wtkbuild] Note: Recompile with -Xlint:deprecation for details.
[unjar] Expanding: D:\eclipse-pulsar-copy-workspace\lib\LWUIT.jar into D:\eclipse-pulsar-copy-workspace\DEMO\build\classes
package:
[wtkjad] Creating JAD file D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jad
[wtkjad] Creating MANIFEST file D:\eclipse-pulsar-copy-workspace\DEMO\dist\MANIFEST.MF
[wtkpackage] Building jar: D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jar
[wtkpackage] Updating JAD file D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jad
obfuscate:
[wtkobfuscate] Obfuscating D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jar with ProGuard
[wtkobfuscate] ProGuard, version 4.8
[wtkobfuscate] Reading input...
[wtkobfuscate] Reading program jar [D:\eclipse-pulsar-copy-workspace\DEMO\dist\DEMO.jar]
[wtkobfuscate] Reading library jar [C:\WTK2.5.2_01\lib\cldcapi11.jar]
[wtkobfuscate] Reading library jar [C:\WTK2.5.2_01\lib\midpapi20.jar]
[wtkobfuscate] Initializing...
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Image2D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Image2D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.M3G: can't find referenced class javax.microedition.m3g.Image2D
[wtkobfuscate] Warning: com.sun.lwuit.M3G$Callback: can't find referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find referenced class javax.microedition.media.control.VideoControl
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileSystemRegistry
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileSystemRegistry
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Warning: com.sun.lwuit.util.Log: can't find referenced class javax.microedition.io.file.FileConnection
[wtkobfuscate] Note: com.sun.lwuit.M3G: can't find dynamically referenced class javax.microedition.m3g.Graphics3D
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.siemens.mp.game.Light
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.motorola.phonebook.PhoneBookRecord
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.nokia.mid.ui.FullCanvas
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class net.rim.device.api.system.Application
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class com.mot.iden.util.Base64
[wtkobfuscate] Note: com.sun.lwuit.impl.midp.GameCanvasImplementation: can't find dynamically referenced class mmpp.media.MediaPlayer
[wtkobfuscate] Note: there were 7 unresolved dynamic references to classes or interfaces.
[wtkobfuscate] Warning: there were 31 unresolved references to classes or interfaces.
[wtkobfuscate] You should check if you need to specify additional program jars.
[wtkobfuscate] You may need to specify additional library jars (using '-libraryjars').
[wtkobfuscate] java.io.IOException: Please correct the above warnings first.
[wtkobfuscate] at proguard.Initializer.execute(Initializer.java:321)
[wtkobfuscate] at proguard.ProGuard.initialize(ProGuard.java:212)
[wtkobfuscate] at proguard.ProGuard.execute(ProGuard.java:87)
[wtkobfuscate] at proguard.ProGuard.main(ProGuard.java:493)
BUILD FAILED
D:\eclipse-pulsar-copy-workspace\DEMO\build.xml:75: Obfuscation failed (result=1)
Total time: 28 seconds
如何成功构建?
感谢和问候
答案 0 :(得分:2)
这与build.xml无关。您正在链接LWUIT.jar,它是通用库,而不是您想要的LWUIT的MIDP版本。