Why doesn't BlackBerry App Close in Latest OS?


I’m creating a BlackBerry 10 app using OpenFl and its been going well until recently. Last week, I upgraded my device to the latest OS version ( and now my app doesn’t exit properly.

The precise behaviour is this:
The first time I open my app on my Z10, it runs fine. But when I try to exit, the window it’s been running in disappears and the app icon becomes faded and semi-transparent (like it’s got an alpha of 0.5 or so). Normally, the icon doesn’t look like this.

From doing some research, I believe the fading indicates that the app didn’t close properly. If I click on the icon, nothing happens. I can’t open my app again without restarting my BlackBerry device. Any ideas what’s going on?

The weird thing is that my app was working just fine on an earlier developer build of 10.3.1 (, I believe).

I’ve tested with a simple Hello World app & got the same bug. The follow steps should be enough to reproduce it:

  1. Update your BB10 device to the latest OS ( via Settings > Software Updates
  2. Open FlashDevelop and create a new OpenFl project that uses a standard template.
  3. Do a debug or release build of the project for the BlackBerry target.
  4. Install the resulting BAR file on your BB10 device and click on the icon to open it.
  5. Once the app is open, do the swipe gesture to put it into the background.
  6. Press on the X to close the app.
  7. The app icon should now look faded. Clicking on it won’t open the app again. You’re stuck unless you restart your device.

Any ideas what’s going on?

I know about the log file on BlackBerry devices & I checked it to see if had an error messages. I did not.

This leads me to believe that the app isn’t actually crashing Instead, it’s actually in some sort of “limbo” state where it hasn’t fully closed but is unresponsive.

Checking out the BlackBerry developer forums, I came across a few other people with the same issue.

Unfortunately, the solutions suggested involved directly adding new c++ code.

My current hunch is that the source of the bug is either:

  1. Because I’m compiling with the old PlayBook OS NDK rather than the newer BB10 NDK.
  2. An issue with a “broken” library - similar to the issue with BB 10.3 that Joshua alludes to here.

I’m currently trying to update from the BlackBerry Native SDK to the BB10 NDK & use it with OpenFl but am having trouble doing this.

Here are the steps I’ve taken:

  1. Downloaded the latest BB10 NDK 10.3.1

  2. First, I simply tried executing the command “lime setup blackberry” & pointing to the directory of the new SDK when prompted for “Path of BlackBerry Native SDK”.
    But this didn’t work & I got an error message along the lines of “Could not find bbndk-env.bat”

  3. I noticed that the new BB10 NDK had the file “bbndk_10_3_1_995.bat” so I searched the source code of both Openfl and Lime and found that five files that included the following line:
    fileName += “\bbndk-env.bat”;

So, I manually changed it to:
fileName += “\bbndk-env_10_3_1_995.bat”;

The files are:
platformSetup.hx (There are 2 copies one in lime/tools & one in openfl-tools)
blackBerryHelper.hx (There are 2 copies one in lime/tools & one in openfl-tools)

Next, I executed the following commands from the command line:

  1. “lime rebuild tools”
  2. “lime setup blackberry”

I then went back into FlashDevelop & tried to build a simple program for the blackberry target.

The compilation process didn’t spit out the previous error & got much further. But eventually, it stopped with the following error:

ntoarmv7-g++ -Iinclude -c -g -IC:/HaxeToolkit/haxe/lib/hxcpp/3,1,48/include -I%BASE_DIR_REPLACED%/target_10_3_1_995/qnx6/usr/include -DBLACKBERRY=BLACKBERRY -fvisibility=hidden -fdollars-in-identifiers -DHXCPP_DEBUG -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=311 -fpic -fPIC -x c++ -frtti ./src/sys/io/FileOutput.cpp -o./obj/blackberry-debug-v7/b6bb5383_FileOutput.o

ntoarmv7-g++ -Iinclude -c -g -IC:/HaxeToolkit/haxe/lib/hxcpp/3,1,48/include -I%BASE_DIR_REPLACED%/target_10_3_1_995/qnx6/usr/include -DBLACKBERRY=BLACKBERRY -fvisibility=hidden -fdollars-in-identifiers -DHXCPP_DEBUG -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=311 -fpic -fPIC -x c++ -frtti ./src/sys/io/File.cpp -o./obj/blackberry-debug-v7/b6bb5383_File.o

ntoarmv7-g++ -Iinclude -c -g -IC:/HaxeToolkit/haxe/lib/hxcpp/3,1,48/include -I%BASE_DIR_REPLACED%/target_10_3_1_995/qnx6/usr/include -DBLACKBERRY=BLACKBERRY -fvisibility=hidden -fdollars-in-identifiers -DHXCPP_DEBUG -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=311 -fpic -fPIC -x c++ -frtti ./src/openfl/text/TextFieldType.cpp -o./obj/blackberry-debug-v7/179d51f1_TextFieldType.o

Process creation failure : ntoarmv7-g++

ntoarmv7-g++ -Iinclude -c -g -IC:/HaxeToolkit/haxe/lib/hxcpp/3,1,48/include -I%BASE_DIR_REPLACED%/target_10_3_1_995/qnx6/usr/include -DBLACKBERRY=BLACKBERRY -fvisibility=hidden -fdollars-in-identifiers -DHXCPP_DEBUG -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=311 -fpic -fPIC -x c++ -frtti ./src/openfl/utils/Endian.cpp -o./obj/blackberry-debug-v7/9bb80065_Endian.o

Build halted with errors (haxelib.exe).

I think the issue is that %BASE_DIR_REPLACED% is not being set an environment variable. If so, how can I fix this. Can I try to do it manually?

When I trace Sys.environment, I get “#function0

When I trace project.environment inside blackBerryHelper.hx, I get the following:
project.environment={NEKO_INSTPATH => C:\HaxeToolkit\neko, Platform => BNB, USERDOMAIN => PI, LOCALAPPDATA => C:\Users\dpope\AppData\Local, PROCESSOR_ARCHITECTURE => x86, ProgramFiles(x86) => C:\Program Files (x86), included => 1, USERPROFILE => C:\Users\dpope, NUMBER_OF_PROCESSORS => 4, TEMP => C:\Users\dpope\AppData\Local\Temp, WEBWORKS_HOME => C:\Program Files (x86)\BlackBerry\BB10 WebWorks SDK, BURN_AUTOPLAY => C:\Program Files (x86)\Roxio\Roxio Burn, PROCESSOR_ARCHITEW6432 => AMD64, BLACKBERRY_SETUP => true, CommonProgramFiles => C:\Program Files (x86)\Common Files, COMPUTERNAME => PI0004551, Damian’s home dir => C:\Users\dpope, ProgramW6432 => C:\Program Files, HOMEDRIVE => C:, SystemRoot => C:\windows, BLACKBERRY_WEBWORKS_SDK => C:\Program Files (x86)\BlackBerry\BB10 WebWorks SDK, asl.log => Destination=file, BLACKBERRY_DEVICE_PASSWORD => pitp, HAXELIB_RUN => 1, PUBLIC => C:\Users\Public, VBOX_INSTALL_PATH => C:\Program Files\Oracle\VirtualBox, KMP_DUPLICATE_LIB_OK => TRUE, native => , BLACKBERRY_NDK_ROOT => c:\bbndk, openfl-native => , BLACKBERRY_DEBUG_TOKEN => C:\bbndk-2.1.0\host\win32\x86\usr\bin\BHE-BB10-native.bar, PROCESSOR_IDENTIFIER => Intel64 Family 6 Model 42 Stepping 7, GenuineIntel, CommonProgramW6432 => C:\Program Files\Common Files, LIB => C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib, OS => Windows_NT, PATHEXT => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC, PCBRAND => p, PROCESSOR_REVISION => 2a07, APPDATA => C:\Users\dpope\AppData\Roaming, PTSMInstallPath_X86 => c:\Program Files (x86)\Hewlett-Packard\HP ProtectTools Security Manager, lime-legacy => 1, INCLUDE => C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include, PSModulePath => C:\windows\system32\WindowsPowerShell\v1.0\Modules, VS120COMNTOOLS => C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools, LOGONSERVER => \SATURN, ProgramData => C:\ProgramData, HAXE_SERVER_PORT => 0, QNX_HOST => %BASE_DIR_REPLACED%/host_10_3_1_12/win32/x86, OnlineServices => Online Services, SystemDrive => C:, TMP => C:\Users\dpope\AppData\Local\Temp, FP_NO_HOST_CHECK => NO, SESSIONNAME => Console, BLACKBERRY_DEVICE_IP =>, openfl => , Path => C:\HaxeToolkit\neko;C:\HaxeToolkit\haxe;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared;C:\Program Files\WIDCOMM\Bluetooth Software;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared;C:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared;C:\Program Files (x86)\Roxio\OEM\AudioCore;C:\Program Files (x86)\Intel\Services\IPT;C:\Program Files\MiKTeX 2.9\miktex\bin\x64;C:\Program Files\MATLAB\R2012a\bin;C:\Program Files\Google\Google Apps Sync;C:\Program Files\Google\Google Apps Migration;C:\Program Files\OpenVPN\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Android\adt-bundle-windows-x86_64-20131030\sdk\tools;C:\Program Files (x86)\Android\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;C:\Program Files (x86)\Java;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files (x86)\Windows Live\Shared;C:\HaxeToolkit\neko;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files (x86)\BlackBerry\BB10 WebWorks SDK;C:\Program Files (x86)\BlackBerry\BB10 WebWorks SDK\cordova-blackberry\bin\dependencies\bb-tools\bin;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, ALLUSERSPROFILE => C:\ProgramData, USERDNSDOMAIN => PI.LOCAL, USERNAME => dpope, .ssh folder => C:\Users\dpope.ssh, CommonProgramFiles(x86) => C:\Program Files (x86)\Common Files, HAXEPATH => C:\HaxeToolkit\haxe, ComSpec => C:\windows\system32\cmd.exe, PROCESSOR_LEVEL => 6, EMC_AUTOPLAY => C:\Program Files (x86)\Common Files\Roxio Shared\OEM, windir => C:\windows, ProgramFiles => C:\Program Files (x86), HOMEPATH => \Users\dpope, PROMPT => $P$G}

Any help’s appreciated. Especially with upgrading to the BB10 NDK. Thanks!


Hello Again OpenFl’ers!

An update on my issue:
I’ve made some progress but haven’t fixed it completely.

Specifically, I’ve been able to build for the BlackBerry target using the BB10 native SDK instead of the outdated PlayBook native SDK that’s currently used by OpenFl.

Unfortunately, this didn’t fix my bug. My app still doesn’t exit properly in the latest version of the BB10 OS ( But at least I know it’s NOT because it was using the PlayBook SDK. Even when I used the latest native SDK (10.3.1), I still get the same bug. The problem lies elsewhere!

The weird thing is that my app exits OK in slightly earlier OS versions (eg. BB10 So, I now believe that this is just the way the OS works. It’s either intentional or, more likely, a bug.

Two questions:
*BlackBerry has a special cpp library that can handle the exit process manually. I think I’ll have to write a native extension that includes it to fix my problem. Is this a good idea? Any other suggestions?

*I’ve read forum posts by Pozirk, so I know his games are in OpenFl. I downloaded them from the BlackBerry app store (great games, BTW!) and they exit fine. So, I know you can get proper exit behaviour in BB10 Pozirk, can I ask - do you do anything special to handle exit behaviour?



Does this occur with basic samples, particularly, I’m curious if this has anything to do with basic samples (like DisplayingABitmap) versus samples that use audio (like PiratePig)

Thanks for the reply @singmajesty!

I just tried three samples & still got the same exit bug with all of them:

So, still not sure what’s going on. I’ll keep trying!


I’m struggling to decide what to do. I’ve tried to contact developer relations with questions regarding the platform, and cannot get in touch with anyone.

If I try and use a leaked release for my phone, then I lose the ability to make calls, due to how my carrier is set up.

I’m not quite certain what the best path forward is for setup, or for making sure that things continue to work reliably.

Ok, I’ve had the same issue with app not closing properly (icon is fading and app still running in background and draining my battery like crazy :)) on my BB Z10 (OS 10.3).
It only happens with debug version of the app, release version works properly.
I hope, that will help!

I think there’s a new OTA (or two), perhaps it fixes the regression

@pozirk, thanks so much. Your suggestion worked. Problem solved! I’ve been trying to fix it for the last two weeks. So, it was a HUGE help. I owe you a beer :smile:

I had previously compiled in FlashDevelop using release mode but the exit bug still persisted - at least when I used with a debug token. When I signed my bar file and then deployed it to my device, the bug disappeared. Thanks again!

@singmajesty I updated to the latest OS my carrier pushed to me (BB10.3.1.1767) yesterday. But the same bug was still there.

BTW, regarding contacting dev. relations, I’m lucky enough to live in Waterloo, Ontario, home of BlackBerry. Their dev relations team has a [drop-in centre][1] where anyone can go in & ask questions.

I’m more than happy to personally bug them to respond to your questions :smile: Actually, I was there a couple of weeks ago & when I told them I used OpenFl, they said that “the guy who made it used to work for BlackBerry” and they knew your name.

Maybe I could try to get the email address of a specific individual on their team with expertise in their native development platform that I could pass onto you. Also, maybe some sort of commitment to try to reply to you. (At least I could give it a go.)

Let me know if I can help out!

[1]: http://narwhal.embo.ca/blackberry/