{"id":495,"date":"2017-04-25T17:44:32","date_gmt":"2017-04-25T17:44:32","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=495"},"modified":"2017-04-25T17:44:32","modified_gmt":"2017-04-25T17:44:32","slug":"nativescript-android-crashing-issues","status":"publish","type":"post","link":"http:\/\/fluentreports.com\/blog\/?p=495","title":{"rendered":"NativeScript: Android &#038; Crashing issues"},"content":{"rendered":"<p>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.\u00a0\u00a0\u00a0 As a community service I want to inform you on how to deal with them.<\/p>\n<p>The first issue is fairly simple to duplicate; open your app in Android 7, and then open it in split screen mode.\u00a0 At this moment there is a issue in the android runtimes that causes your app to crash and burn.\u00a0\u00a0 Assuming you do not want to see\u00a0 your customers complain about application crashes, Nick came up with a good <a href=\"https:\/\/github.com\/NativeScript\/NativeScript\/issues\/4015\">workaround <\/a>until they can fix the <a href=\"https:\/\/github.com\/NativeScript\/NativeScript\/issues\/4015\">issue.<\/a><\/p>\n<p>To fix the issue you need to open your <code>\/app\/App_Resources\/Android\/AndroidManifest.xml<\/code> file and navigate to following key to the <strong>Activity<\/strong> section of the file.\u00a0\u00a0\u00a0\u00a0 It should look like this:<\/p>\n<p><a href=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-496\" src=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity1.jpg\" alt=\"\" width=\"706\" height=\"399\" srcset=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity1.jpg 706w, http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity1-300x170.jpg 300w, http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity1-624x353.jpg 624w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/a><\/p>\n<p>You want to add <code>android:resizableActivity=&quot;false&quot;<\/code> to the <strong>Activity<\/strong> section as shown in this image.<\/p>\n<p><a href=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-497\" src=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity2.jpg\" alt=\"\" width=\"707\" height=\"412\" srcset=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity2.jpg 707w, http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity2-300x175.jpg 300w, http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2017\/04\/manifestactivity2-624x364.jpg 624w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/a><\/p>\n<p>This will disable the ability for the application to be resized; which will eliminate the crash.\u00a0\u00a0 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 <strong>all<\/strong> your apps to eliminate at least one place your app can easily crash on Android 7.<\/p>\n<p>&nbsp;<\/p>\n<p>The <a href=\"https:\/\/github.com\/NativeScript\/android-runtime\/issues\/720\">second issue<\/a> is one that I have been dealing with for month; my remote error logging shows this log frequently:<\/p>\n<p class=\"gh-header-title\"><strong><span class=\"js-issue-title\">Error (native) com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=-xxxxxx<\/span><\/strong><\/p>\n<p>This of course crashes the application.\u00a0\u00a0\u00a0 Well Peter (on the NativeScript Android team) has managed to duplicate and fix at least one of the ways this can occur.\u00a0\u00a0\u00a0 So, we will be seeing this fix in the the new 3.0.0 runtimes.\u00a0\u00a0 WooHoo, less customer crashing is AWSOME news...<\/p>\n<p>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...\u00a0 Guess what this intrepid developer has <a href=\"https:\/\/github.com\/NativeScript\/android-runtime\/issues\/740\">tried and confirms<\/a> works properly.\u00a0\u00a0 You can run the 2.5 TNS core modules and the 2.5 widgets with the Android 3.0.0 android runtimes.\u00a0\u00a0\u00a0 This is not going to be guaranteed to work for any future releases past 3.0,\u00a0 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.\u00a0\u00a0\u00a0 One word of warning you <strong>MUST<\/strong> use 2.5 core-modules with the 2.5 widgets; DO NOT try to mix these up these versions.<\/p>\n<p>Now 3.0 is not yet out of RC status; so I wouldn't deploy this right this minute.\u00a0 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...<\/p>\n<p>To update you just do:<\/p>\n<p><code>tns platform remove android<\/code><br \/>\nand then<br \/>\n<code>tns platform add android@3.0.0<\/code><\/p>\n<p>Please note; you will also want to disable the snapshot feature.\u00a0 It is tied to the core modules and runtime engine.\u00a0 At this moment there is no version of the snapshot for v2.5 core on a 3.0 android engine.\u00a0\u00a0 To disable the snapshot ability; the easiest way is to do:<\/p>\n<p><code>npm remove --save-dev nativescript-dev-android-snapshot<\/code><\/p>\n<p>This will remove all the snapshot code from your project so it won't run and mess anything up...<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0\u00a0\u00a0 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&hellip; <a class=\"more-link\" href=\"http:\/\/fluentreports.com\/blog\/?p=495\">Continue reading <span class=\"screen-reader-text\">NativeScript: Android &#038; Crashing issues<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-495","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"_links":{"self":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=495"}],"version-history":[{"count":1,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/495\/revisions"}],"predecessor-version":[{"id":498,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/495\/revisions\/498"}],"wp:attachment":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=495"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}