Monthly Archives: April 2017

NativeScript: Android & Crashing issues

This is more of an informational post; there are a couple issues that I am aware of that will kill your application deader than a door nail.    As a community service I want to inform you on how to deal with them.

The first issue is fairly simple to duplicate; open your app in Android 7, and then open it in split screen mode.  At this moment there is a issue in the android runtimes that causes your app to crash and burn.   Assuming you do not want to see  your customers complain about application crashes, Nick came up with a good workaround until they can fix the issue.

To fix the issue you need to open your /app/App_Resources/Android/AndroidManifest.xml file and navigate to following key to the Activity section of the file.     It should look like this:

You want to add android:resizableActivity="false" to the Activity section as shown in this image.

This will disable the ability for the application to be resized; which will eliminate the crash.   The NativeScript team is investigating how to fix it; so eventually you won't need to do this; but in the meantime, I would recommend you add this to all your apps to eliminate at least one place your app can easily crash on Android 7.


The second issue is one that I have been dealing with for month; my remote error logging shows this log frequently:

Error (native) com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=-xxxxxx

This of course crashes the application.    Well Peter (on the NativeScript Android team) has managed to duplicate and fix at least one of the ways this can occur.    So, we will be seeing this fix in the the new 3.0.0 runtimes.   WooHoo, less customer crashing is AWSOME news...

Now I know what a lot of you are thinking, I've got a NativeScript 2.5 application; I don't want to upgrade to 3.0 yet; it will break all my plugins...  Guess what this intrepid developer has tried and confirms works properly.   You can run the 2.5 TNS core modules and the 2.5 widgets with the Android 3.0.0 android runtimes.    This is not going to be guaranteed to work for any future releases past 3.0,  but for the first couple versions, you should be very safe running the Android 3.0 runtimes with 2.5 NS Core Modules and 2.5 NS Core Widgets.    One word of warning you MUST use 2.5 core-modules with the 2.5 widgets; DO NOT try to mix these up these versions.

Now 3.0 is not yet out of RC status; so I wouldn't deploy this right this minute.  But once 3.0 is out; I plan on updating my apps to use the 3.0 engine to eliminate this nasty issue that randomly crashes my applications...

To update you just do:

tns platform remove android
and then
tns platform add android@3.0.0

Please note; you will also want to disable the snapshot feature.  It is tied to the core modules and runtime engine.  At this moment there is no version of the snapshot for v2.5 core on a 3.0 android engine.   To disable the snapshot ability; the easiest way is to do:

npm remove --save-dev nativescript-dev-android-snapshot

This will remove all the snapshot code from your project so it won't run and mess anything up...