views:

579

answers:

2

I've written a Blackberry appliation with the Blackberry JDE, running on a 9000 simulator. I tested it a week or so ago and loaded it on a Blackberry 9000 phone, and everything worked just fine. Sometime between then and now, though, something went wrong.

My code does the whole moving arrow "loading things from the internet" or whatever thing, but no screens pop up. My original screen, which is just a MainScreen with a RichTextField doesn't load at all. This screen, at least, has most likely not changed in the passing week, so if something broke, it would be in one of the later screens/lines of code that it shouldn't even be getting to yet!

Is it possible that my .jad or .cod file are corrupted somehow? I noticed that when I first put code on my machine, I just stuck in the .cod file that Eclipse provided me. Then, last week, the .cod file it gave me didn't work, because it was ACTUALLY a zip file with a two .cod files inside of it. Using the .cod file with the same name as the .cod file they were in succesfully loaded my app. I did the same this time, and I don't get invalid cod file errors or anything, but the app is still as broken.

Is there some direction I should be looking? Is the issue likely to be in my code, the cod file, the phone, or somewhere completely else?

-Jenny

Edit: I've narrowed it down to the problem only occuring if I attempt to load a particular screen. My problem is that this screen is nearly identical to another screen that IS working just fine on the actual device. Both screens are generated from the same method (which makes a webservice call and gets XML back and parses it to populate the fields of the screen). The only difference is that the screen that is breaking is going to a different URL. This URL DOES work (both from a browser and from the simulated device), so I"m at a loss. The application doesn't seem to crash, (it's still running in the background), it just doesn't attempt to display anymore.

Edit:

Okay, I'm seeing some tunneling errors immediately after I load my app, (but before I execute any of my networking code). When i do execute my networking code, it works just fine, unless it happens to be for my "Rental" section. I commented out all calls to that, and made my menu item for Rentals simply make a print statement. The code behaves identically (it freezes, or displays a white screen after selecting the button). All other menu items work (including those that call threads or network methods). And the rentals menu sucessfully executes in the simulator.

      private MenuItem _rentals = new MenuItem("My Rentals", 110,
        10) {
       public void run() {
        //if the last thing I did was a rental
        //just show the screen
        //else, reload rentals
        System.out.println("Rentals was selected");
        displayError("Rentals was pressed");

//      if(rental){
//       System.out.println("It's a rental!");
//       popScreen(getActiveScreen());
//       pushScreen(_offeringsScreen);
//      }else{
//       System.out.println("Getting Rentals from scratch");
//       RentalsThread _rThread = new RentalsThread();
//       _rThread.start();                 
//      }

       }};

I'm at a complete loss here: The device debugger doesn't seem to even register me selecting the menu item, and not a single line of code executes! It just freezes! I'll try putting back in my RentalsThread call in the start of my program (which was also freezing) just to see if I can tease apart the problem with the Rentals Thread (which makes the Rental Screen), and the problem with the Rentals menu item.

A: 

several suggestions:

  • if you have some background work with resources like file IO or networking, app just may stuck there... provide error handling and try to debug app from device!
  • code signing, check latest code update for API which require signing. But since there are no errors this is doubtful.

To debug on device, run Blackberry Device Manager, attach phone to usb, in eclipse select project, Context Menu -> Debug As -> Blackberry Device.
See A50 How to Debug and Optimize

UPDATE I see "Tunnel failed" exception, so it's like network connection problem...
See tunnel failed in blackberry bold. why?
How to Configure Full Internet Access On BlackBerry

UPDATE Support - Application stops responding when opening a connection

Max Gontar
I don't THINK that's what's happening...I'm specifically loading a simple screen first, THEN doing all the complex things. The simple screen should display even before anything else happens... Then again, if I comment out everything but that simple screen it seems to work...
Jenny
I'm noting that what seems to be the issue is that if a particular screen attempts to load (no matter how or when I try to load it), the app freezes. Otherwise, everything else works just fine (in the original program, that screen would load once all of it's content was ready, right after the initial simple screen, thus why it would break immediatly)
Jenny
again, have you tried to debug on device? and if you have doubts about some code parts, please post them (ex. how you load particular screen or what happens after that simple screen is loading).
Max Gontar
I'm not really sure how to "debug on device". I'm downloading my code from a server I"m running. We have a Blackberry USB cable, and a coworker wrote some code to get stack traces from that, but something is going wrong with that right now and he's debugging THAT. I don't think you're talking about something like that, though. Is this something for Eclipse, or the default JDE? How would I do it?
Jenny
Nevermind, I figured out I had to download that Desktop Manager thing to get my computer to recognize that I had a blackberry hooked up to it.
Jenny
I'm actually really confused ont hat. I get those tunnel errors...but then immediately after getting them, my application can succesfully connect via the network to every screen but the one that it has already been erroring on. And I get those tunnel errors BEFORE a single line of my code seems to execute.
Jenny
+2  A: 

Okay, I think I have this figured out.

1.) My code was still behaving identically even after commenting out everything because I wasn't rebuilding the .COD files (they automatically rebuild if you try to run it in the simulator, but don't when you're generating a .ALX file, for some reason).

2.) The code I had for generating the Rental Screen was adding things to said screen. Apparently this is all well and good on the simulator, but on the real device it's required that you do all graphics manipulation (even for graphics not yet displayed) in an event thread (I used invokeAndWait).

So, now everything seems to be working just fine. There wasn't anything wrong with my networking (nor did I think there was, because my other networking screen works just fine). I still don't know why I get all those weird tunneling network things before I start, but it doesn't seem to affect anything yet.

See also:
BlackBerry UI Threading - The Very Basics
BlackBerry threading model

Jenny