{"id":140,"date":"2015-09-16T17:57:41","date_gmt":"2015-09-16T17:57:41","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=140"},"modified":"2015-09-17T21:49:14","modified_gmt":"2015-09-17T21:49:14","slug":"upgrading-to-nativescript-v1-3-from-earlier","status":"publish","type":"post","link":"http:\/\/fluentreports.com\/blog\/?p=140","title":{"rendered":"Upgrading to NativeScript v1.3 from earlier versions."},"content":{"rendered":"<p>To update you need to upgrade a couple items, recommended that you do it in order.\u00a0\u00a0 Also, a word of caution once you upgrade your NativeScript CLI, you need to upgrade your platform and common modules for any of your other projects.\u00a0\u00a0 It is supposed to be backwards compatible; but I was not successful in getting the new version of TNS CLI to compile an older project properly.\u00a0 Rather than spend any amount of time trying to get it to work, it was simpler just to upgrade the platform and common core modules...<\/p>\n<p>Make sure you are NOT running Node v4.00; The current v4.00 version of Node does NOT work.\u00a0\u00a0 If you need to downgrade node, I recommend you grab the latest version of Node v0.12.x from <a href=\"https:\/\/nodejs.org\/download\/release\/latest-v0.12.x\/\">https:\/\/nodejs.org\/download\/release\/latest-v0.12.x\/<\/a>.\u00a0\u00a0 If you are already running node and it is working for you; you don't need to upgrade it.\u00a0 This note is just to make sure you DON'T upgrade node to v4.00.<\/p>\n<p>Next thing if you are doing anything with Android; you want to do is type \"gradle --version\" and see if it runs.\u00a0 If it doesn't run from the command line you need to either install <a href=\"https:\/\/gradle.org\/\">gradle<\/a> or set your path to use it.\u00a0\u00a0 If you have Android Studio installed; gradle is including with Android Studio, so you don't have to install it again.\u00a0 For example on my Windows machine; my gradle is located at: <em>C:\\Program Files (x86)\\Android\\android-studio\\gradle\\gradle-2.4\\bin. \u00a0<\/em> So I added that to my path, so now gradle can run from anywhere.\u00a0 If you are using Ubuntu, the version included is really old and you will need to install a ppa from: <a href=\"https:\/\/launchpad.net\/~cwchien\/+archive\/ubuntu\/gradle\">https:\/\/launchpad.net\/~cwchien\/+archive\/ubuntu\/gradle<\/a> Then you will be able to do a <strong>sudo apt-get update &amp;&amp; sudo apt-get install gradle<\/strong> and get a much more recent version.\u00a0\u00a0 On a Macintosh, it is recommended you install <a href=\"http:\/\/brew.sh\/\">brew<\/a>, and then do a <strong>brew install gradle<\/strong>.\u00a0\u00a0 You can alternatively download and install it directly from <a href=\"https:\/\/gradle.org\/\">https:\/\/gradle.org\/<\/a>.\u00a0\u00a0 You must be running at least v2.3 of Gradle.<\/p>\n<p><b>Edit 2015\/09\/17:<\/b> The new version of the build system uses gradle and the gradle configuration file REQURIES that you are running v22.0.1 of the Android Build tools.  In the grunt based build system you could use v21 or v23.0.1.  Since this has caught a few people; you will want to open up the Android SDK installer, and make sure to install Build Tools v22.0.1<\/p>\n<p>The next thing you need to make sure is that you have your ANDROID_HOME and JAVA_HOME environmental variables set.\u00a0\u00a0 If you don't have them set you will get error messages about these needing to be set.\u00a0 On Windows you can do <strong>echo %ANDROID_HOME%\u00a0 %JAVA_HOME%<\/strong> to see if they are set.\u00a0 On Macintosh and Linux you can do <strong>echo $ANDROID_HOME $JAVA_HOME<\/strong> to see them.<\/p>\n<p>So, now that you have your environment all setup; we need to upgrade the NativeScript Command Line utility, first.\u00a0 This is very important, before you even attempt to upgrade the platform modules you <strong>MUST <\/strong>be running the new version of the NativeScript CLI.<\/p>\n<p>The easiest way is to do a: <strong>npm remove nativescript -g\u00a0\u00a0 <\/strong>Yes, we want to de-install the current version; trust me it is easier this way.\u00a0 You can do a in-place update; but the times I tried it it threw errors; and I had to do it a couple times to get it installed.\u00a0\u00a0 So, it is much easier just to de-install it. Then you just type:\u00a0 <strong>npm install nativescript\u00a0 -g <\/strong>to re-install it.<\/p>\n<p>If everything worked fine; you should be able to do: <strong>tns --version<\/strong> and you will see v1.3.0<\/p>\n<p>The next piece you need to do is upgrade your platform.\u00a0 Before you upgrade; you will want to make sure you backup any changes you made in the platform folder as both methods can overwrite the project files.\u00a0 You can do it one of two ways; my way or the simpler way.\u00a0\u00a0 Telerik recommends the simpler way; you do a <strong>tns platform update android <\/strong>or <strong>tns platform update ios<\/strong>.\u00a0\u00a0\u00a0 In most cases this works great.\u00a0\u00a0 However, in some of the past updates it has left you with a broken platform and then you still had to do it my way to fix it.\u00a0\u00a0\u00a0 So rather than have the chance that you will get a broken platform, I of course will recommend my way.<\/p>\n<p>My way is the nuclear option!\u00a0 <strong>tns platform remove android<\/strong> and then <strong>tns platform add android<\/strong>.\u00a0\u00a0 I remove and then re-add back the platform.\u00a0\u00a0 Now, this will totally DELETE your platform\/android or platform\/ios folders.\u00a0 So if you made any customization to your project files; I'm going to re-stress this -- you will want to back them up first.<\/p>\n<p>The final piece is updating the common core tns-core-modules; in past versions of nativescript this was a bit of a pain to upgrade.\u00a0 No more, it is now very simple!\u00a0\u00a0 The first thing you can do is just totally delete your app\/tns_modules folder.\u00a0 It is not used any more, totally ignored and now a waste of disk space.\u00a0\u00a0 Then you just type <strong>npm install tns-core-modules --save<\/strong> from inside your root project folder.\u00a0\u00a0\u00a0 This will install the core modules in the node_modules folder like any other nativescript plugin.\u00a0 So now in the future you can do a simple npm update tns-core-modules and have the latest version.<\/p>\n<p>And finally after everything is all done; you can do a:<br \/>\n<strong>tns prepare android <\/strong><br \/>\nand\/or<br \/>\n<strong>tns prepare ios<\/strong><\/p>\n<p>And you should see it confirm everything is good to go...\u00a0\u00a0 Happy hacking on your NativeScript application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To update you need to upgrade a couple items, recommended that you do it in order.\u00a0\u00a0 Also, a word of caution once you upgrade your NativeScript CLI, you need to upgrade your platform and common modules for any of your other projects.\u00a0\u00a0 It is supposed to be backwards compatible; but I was not successful in&hellip; <a class=\"more-link\" href=\"http:\/\/fluentreports.com\/blog\/?p=140\">Continue reading <span class=\"screen-reader-text\">Upgrading to NativeScript v1.3 from earlier versions.<\/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":[3,15],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-javascript","category-nativescript","entry"],"_links":{"self":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/140","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=140"}],"version-history":[{"count":5,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":146,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions\/146"}],"wp:attachment":[{"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}