×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341

    Will Not Run on Real Device

    Hello,
    My application is running on the emulator just fine but it will not run on the device, 3660. The splash screen is displayed and then it crashes and I get "NullPointerException".

    The splash code:
    class SplashScreen extends FullCanvas
    {
    private final int SPLASH_DELAY = 5000;
    private Image splashImage = null;
    private Display display;
    private Timer timer = new Timer();
    private SplashFunctions splashFunctions;
    private class CountDown extends TimerTask
    {
    public void run()
    {
    dismiss();
    }
    }
    SplashScreen(Display display, SplashFunctions splashFunctions)
    {
    try
    {
    splashImage = Image.createImage(176, 208);
    Image lbl = Image.createImage("/spll.png");
    Image img = Image.createImage("/splf1.png");
    Graphics g = splashImage.getGraphics();
    g.setColor(102, 51, 0);
    g.fillRect(0, 0, 176, 208);
    g.drawImage(lbl, 176/2 - lbl.getWidth()/2, 5, Graphics.TOP|Graphics.LEFT);
    g.drawImage(img, 176/2 - img.getWidth()/2, lbl.getHeight()+15, Graphics.TOP|Graphics.LEFT);
    img = null;
    lbl = null;
    }
    catch(Exception e){}
    this.display = display;
    this.splashFunctions = splashFunctions;
    }
    protected void keyPressed(int keyCode)
    {
    dismiss();
    }
    protected void showNotify()
    {
    timer.schedule( new CountDown(), SPLASH_DELAY);
    }
    public void dismiss()
    {
    if (timer != null)
    timer.cancel();
    if (splashFunctions != null)
    splashFunctions.splashDismissed();
    splashImage = null;
    timer = null;
    splashFunctions = null;
    System.gc();
    }
    public void paint(Graphics g)
    {
    if (splashImage != null)
    g.drawImage(splashImage, 0, 0, Graphics.TOP|Graphics.LEFT);
    }
    }

    interface SplashFunctions
    {
    public void splashDismissed();
    }
    interface Functions
    {
    //public void pause();
    public void systemPaused();
    public void exitGame();
    public void gameOver(int score);
    }

    public class GameManager extends FullCanvas implements Functions, SplashFunctions
    {
    GameManager(Display display, DryPitsWin parent)
    {
    this.display = display;
    this.parent = parent;
    bShowSplash = true;
    bMenuActivated = false;
    mselection = 0;
    menuitem = MAIN_MENU;
    soundOn = true;
    try
    {
    insl = Image.createImage("/insl.png");
    ins = Image.createImage("/ins.png");
    sndon = Image.createImage("/son.png");
    ssndon = Image.createImage("/sons.png");
    sndoff = Image.createImage("/soff.png");
    ssndoff = Image.createImage("/soffs.png");
    gameovr1 = Image.createImage("/go1.png");
    gameovr2 = Image.createImage("/go2.png");
    ok = Image.createImage("/ok.png");
    back = Image.createImage("/back.png");
    numberImgs = new Image[9];
    for (int i=0; i < 10; i++)
    numberImgs[i] = Image.createImage("/num"+i+".png");
    }
    catch(Exception e){}
    }

    // if the game is starting for the first the splash will be displayed
    // because bShowSplash was set to true in ctor.
    protected void showNotify()
    {
    if (bShowSplash)
    {
    splash = new SplashScreen(display, this);
    display.setCurrent(splash);
    }
    else if (Game.isSysPaused())
    {
    unsysPause();
    }
    }
    // called by splash to indicate it is done
    public void splashDismissed()
    {
    bShowSplash = false;
    splash = null;
    buildMenu();
    // gain focus to mainmenu
    display.setCurrent(this);
    System.gc();
    }

    }


    Somewhere between showNotify() and when the splashscreen calls splashDismissed() I get a "NullPointerExcept" that i am not getting on emulator. The jar file size is 64K which is well below the limit. The phone is new and was just purchased. The application is being loaded via web. the jar file has 30kb of image files in it. would this cause it to crash? Also, when the application is paused by the system I save the game state and delete all graphic files. is it fruitless to delete graphic files? Do they stay in memory until the application is exited? If so, when the application is unpaused and I reload images again, while I have two copies of the images floating around in memory?

    Thanks!

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Bremen, Germany
    Posts
    106
    Hi earamsey,

    I'm not sure if it is a good idea to switch the display in the showNotify() method. Also I see some empty "catches", which do not handle an exception properly.

    You could use the logging framework of J2ME Polish to find the error, e.g.

    Code:
    try {
    	//... loading images
    } catch (Exception e) {
    	//#debug error
    	System.out.println( "Error while loading images" + e );
    }
    You need to enable the showLogOnError-attribute in the build.xml file and use the J2ME Polish GUI. The above message will then be shown on the real device as well.

    More information is at http://www.j2mepolish.org/docs/utilities.html#logging

    Best regards,
    Robert

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341
    Is there a way to make the wtk21 display System.out.print's to the handset too?

  4. #4
    Registered User
    Join Date
    Mar 2003
    Location
    Bremen, Germany
    Posts
    106
    Hi earamsey,

    sorry I don't understand your question. You can view all System.out.println() messages from the application (as long as you have inserted the proper #debug statement before printing the message).

    Maybe you mean the stacktace of an exception? Stacktraces are not accessible from within J2ME, so this is impossible. J2ME Polish offers the "verbose" debugging mode, in which case the source file and the line within the source code is logged for each message.

    Code:
    <debug enable="true" showLogOnError="true" verbose="true" level="error">
            <filter pattern="com.company.package.*" level="info" />
            <filter pattern="com.company.package.MyClass" level="debug" />
    </debug>
    Best regards,
    Robert

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341
    Can I make messages be displayed to the console without the use of Eclipse? I don't want to use Eclipse i've been using ktoolbar gui, simple fast, that comes with the wireless toolkit 2.0

  6. #6
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341
    Sorry abut the last question. Anyway, I am having trouble running ant. I get the following output:

    C:\Program Files\J2ME Polish>ant
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)

    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.



    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -showversion print product version and continue
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    C:\Program Files\J2ME Polish>

    What am I doing wrong? I have ant installed at: C:\apache-ant-1.6.1
    and
    I added "C:\apache-ant-1.6.1\bin" to path
    and I set ANT_HOME=C:\apache-ant-1.6.1\

    Any ideas? I would love to get up to speed quickly with j2me polish! When I get ant running all I have to do is copy my source files over to "j2me polish\src" and type "ant" at the "j2me polish" directory? (c:\j2me polish\> ant)
    is the example build.xml setup for series60 3650 phone? or do I have to make some changes to ant?
    thanks

  7. #7
    Registered User
    Join Date
    Mar 2003
    Location
    Bremen, Germany
    Posts
    106
    Hi earamsey,

    yes you can use any IDE with J2ME Polish.

    Here are the steps you need to do:

    * make sure you use the latest release (current release is J2ME Polish 1.0 RC4).

    * copy your sources to the "src" folder of your J2ME Polish installation (or copy the "build.xml", the "import" folder and the "resources" folder to your project-root).

    * Adjust the "build.xml" file: you need to specify your MIDlet class in the <midlet> element.
    You might also want to adjust the <deviceRequirements> element, currently applications are builded for 4 device-groups:
    1) Nokia Series 60 ("Nokia/Series60"),
    2) Nokia Series 60 with MIDP/2.0 ("Nokia/Series60Midp2"),
    3) Any MIDP/1.0 phone("Generic/midp1"),
    4) Any MIDP/2.0 phone ("Generic/midp2").

    * If you want to use the J2ME Polish GUI, you need to make changes to the "resources/polish.css" file.
    Tip: use dynamic styles like "form" and "list" for a start.
    If you do not want to use the J2ME Polish GUI, disable it by setting the "usePolishGui"-attribute of the <build>-element to "false".

    * Ensure that your Ant-setup is correct, do you have set the JAVA_HOME environment variable? http://www.j2mepolish.org/docs/install.html#antsetup


    --
    Hope everything now works fine!

    Best regards,
    Robert

  8. #8
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341
    can I use visual studio ide? what is the setup?

  9. #9
    Registered User
    Join Date
    Mar 2003
    Location
    Bremen, Germany
    Posts
    106
    Hi earamsey,

    dunno, never tried the Visual Studio... As long as it can run Ant-files it is no problem (right-click on the provided "build.xml" file from Visual Studio and select "Run Ant..." or similar).

    You can use ANY IDE if you run Ant from the command line, by the way. The setup is described at http://www.j2mepolish.org/docs/install.html#antsetup

    Just call "ant" from the project root, or call "ant test j2mepolish" to skip the obfuscation step.

    Best regards,
    Robert

  10. #10
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341
    Hello, i am not getting any debug messages with j2me polish! he is my build.xml file -

    <project
    name="enough-j2mepolish-example"
    default="j2mepolish">

    <!-- The wtk.home property should point to the directory -->
    <!-- containing the Wireless Toolkit. -->
    <property name="wtk.home" value="C:\WTK21" />

    <!-- Definition of the J2ME Polish task: -->
    <taskdef name="j2mepolish" classname="de.enough.polish.ant.PolishTask" classpath="import/enough-j2mepolish-build.jar:import/jdom.jar:import/proguard.jar:import/retroguard.jar"/>


    <!-- build targets, each target can be called via "ant [name]",
    e.g. "ant clean", "ant notest j2mepolish" or just "ant" for calling the default-target -->

    <target name="test" >
    <property name="test" value="true" />
    </target>

    <target name="init">
    <property name="test" value="false" />
    </target>

    <target name="j2mepolish"
    depends="init"
    description="This is the controller for the J2ME build process."
    >
    <j2mepolish>
    <!-- general settings -->
    <info
    license="GPL"
    name="DryPitsWin"
    description="Dry Pits Win"
    vendorName="Erica A Ramsey"
    icon="DryPitsWin.png"
    jarName="DryPitsWin.jar"
    jarUrl="${polish.jarName}"
    copyright="Copyright Erica A Ramsey. All rights reserved."
    deleteConfirm="Do you really want to kill me?"
    />
    <deviceRequirements if="test">
    <requirement name="Identifier" value="Nokia/3650" />
    </deviceRequirements>
    <deviceRequirements unless="test">
    <requirement name="Identifier" value="Nokia/Series60" />
    <!-- on could use other devices for real builds, e.g. :
    <or>
    <and>
    <requirement name="JavaPackage" value="nokia-ui" />
    <requirement name="BitsPerPixel" value="16+" />
    </and>
    </or>
    -->
    </deviceRequirements>
    <!-- build settings -->
    <!-- Here you can set the resDir attribute to "resources2"
    for an alternative design.
    -->
    <build
    symbols=""
    imageLoadStrategy="background"
    fullscreen="menu"
    usePolishGui="false"
    resDir="res"
    destDir="bin"
    >
    <!-- midlets definition -->
    <!--
    <midlet class="de.enough.polish.example.MenuMidlet" name="Example" />
    -->
    <midlet class="DryPitsWin" name="DryPitsWin"/>
    <!-- project-wide variables - used for preprocessing -->
    <variables>
    </variables>
    <!-- obfuscator settings: do not obfuscate when the test-property is true -->
    <obfuscator unless="test" enable="true" name="ProGuard" />
    <!-- debug settings: only include debug setting when the test-property is true -->
    <debug if="test" enable="true" showLogOnError="true" verbose="true" level="error">
    <!--
    <filter pattern="de.enough.polish.example.*" level="debug" />
    -->
    <filter pattern="DryPitsWin" level="debug" />
    </debug>
    <!-- user defined JAD attributes can also be used: -->
    <jad>
    <attribute name="Nokia-MIDlet-Category" value="Game" if="polish.Vendor == Nokia" />
    </jad>
    </build>
    </j2mepolish>
    </target>


    <target name="clean"
    description="allows a clean build. You should call [ant clean] whenever you made changes to devices.xml, vendors.xml or groups.xml">
    <delete dir="build" />
    <delete dir="dist" />
    </target>

    </project>


    inside my program i put:
    //#debug
    System.out.println("inside dismiss()");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×