Error: "Unable to Open App - Close the Current app, and try again."

Hi,

Has anyone encountered this error?

I am writing a widget and glance, which make intervaled web requests using a timer. The error happens when I switch off the Bluetooth connection to the phone and then open and close the widget (which shows an error) a few times. Once it happens, I have to reboot the watch to be able to open the widget again. The glance continues to work without issues.

I have looked at my apps log and it seems on the last exit from the widget before the error occurs, the View.onHide() function of the widget is still called, but AppBase.stop() is not anymore. So it looks like the app hangs somewhere inbetween, isn't probably terminated and therefore cannot start again.

: what is very interesting is that I then get the same error from your WU app. For that one I have not even opened the widget, only the glance. Still, once the error occurs in my app, and I then try to open the WU widget, I get exactly the same error screen.

Has anyone an idea how I could further analyse this? I am not yet experienced on debugging stuff that happens on the watch and have only looked at my apps log files, where I put some System.println() to better understand what is happening. Is there any other place where errors happening in the SDK would be logged to?

Thanks for your help!

  • which device do you see it with the WU widget?.  And what are the exact steps, press by press, etc..

    does it only happen if you run your widget/super app first?

  • I found the issue in my app, I had an bug in my View.onHide() function, an access to the method of an object that would be null if there is no phone connection.

    For future use, is there any place where I can see such runtime errors when they occur on the watch?

    @jim_m_58: yes, it only happened in WU after I had the issue in my app. Now that I have solved it in my app, it also does not occur in WU. So it seems my app did crash something within the OS that your app was also relying on. I guess both apps use web requests, maybe there is something in the communication module that can affect both apps?

    The exact steps were: disable phone Bluetooth, start up watch, go to my glance (without showing WU preview/glance), open my widget, close my widget (back button), do that back and forth until the error occurs. Then scroll to the WU glance, and open the WU widget. Error was there as well.

  • It's not common, but an app has impacted other apps in the past.

  • hi Former Member  could you share which part of your app was causing the issue, and also explain how did you solve this with in your app, also please share the apps you were having issues with.

  • Good morning!

    So my View.onHide() function looks like this:

    function onHide() as Void {
        System.println("Widget: onHide");
        _stateRequest.stop();
    }

    And the called stop() method looks like this:

    public function stop()
    {
        System.println("StateRequest: stop");
        _timer.stop();
        Communications.cancelAllRequests();
        Storage.setValue( "state_data", _data );
        Storage.setValue( "state_dataTimestamp", _dataTimestamp.value() );
    }

    The culprit was the _dataTimestamp.value(). _dataTimestamp would have been null in these scenarios, so the call _dataTimestamp.value() leads to a Null lReference exception. This seems to prevent the application from exiting properly, AppBase.onStop() is not called anymore.

    After that happens, also the widget of the Weather Underground app showed the same error message. If you are interested, I can create a video of how I reproduce the issue.

  • This whole thing brings me to a question on exception handling: I was kind of expecting that the code that calls my functions such as onHide or onStop would handle exceptions, but it seems in this case it does not. Would it be good practice to have a try/catch block in all of these functions and just output the exception to System.println?

  • yes a video would be really helpful, could you also list all the devices you are seeing this?

  • Hi, here is the video. It shows both the issue occurring in my app and then the WU app being affected. I was able to reproduce the issue by causing a Null exception in the onHide function of the app class. Originally not having a phone connection was the cause, but when I throw that Null exception on purpose, the error is also reproducible with phone connection.

    The video was too large for the forum here, but I uploaded it to my website:

    www.pollai.at/.../video-null-exception.mov

    The device is an Epix Pro Gen 2 47mm with latest software.

  • After investigating some other issues I saw the same side-effect between my app and other apps. Basically if my app somehow crashes and hangs in the background, other apps cannot be started anymore. Probably the watch supports only one Connect IQ app to run at the same time?

    Is there a way to terminate a hanging app, apart from rebooting the watch?

  • Indeed there can be only 1 ciq app running, however this sounds like a bug in the firmware. No app should have effect on other apps