{"id":208,"date":"2016-02-04T17:50:13","date_gmt":"2016-02-04T17:50:13","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=208"},"modified":"2016-02-04T17:50:13","modified_gmt":"2016-02-04T17:50:13","slug":"nativescript-keeping-your-androidmanifest-xml-easily-editable-and-under-version-control","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=208","title":{"rendered":"NativeScript: Keeping your AndroidManifest.xml easily editable and under version control."},"content":{"rendered":"<p>So here I was again minding my own business on the forums again, and Ben posted he had been attempting to use this new feature of v1.5.x of NativeScript and it was failing.\u00a0 I responded it didn't work like that.\u00a0\u00a0 Thankfully he was persistent and ignored my wrong response, and linked to the github issue a second time where they discuss the new feature.\u00a0\u00a0 Him, being persistent despite me telling him it doesn't work that way; is why we now have a way to make it work!\u00a0\u00a0 So thank you Ben!<\/p>\n<p>So I went and looked at the new feature and found that by default it doesn't work as a normal person would expect.\u00a0\u00a0\u00a0 It does exactly what I expected and why I said it doesn't work.\u00a0\u00a0\u00a0 However, I decided to see if I could make it work the way any sane person would want it to and guess what, I have a method to make this work perfectly.<\/p>\n<p>To make this work properly;\u00a0 you need NativeScript v1.5.1 or later; so type tns --version and make sure you are running v1.5.1 and later, if not upgrade.<\/p>\n<p><strong>WARNING:<\/strong> changing things in your platforms folder can completely break your build; and if you totally break your build you can do a <strong>tns platform remove android<\/strong> and then a <strong>tns platform add android<\/strong> to reset it.<\/p>\n<p>First, you will need to navigate to your <em>\/platforms\/android\/src\/main<\/em> and copy the <em>AndroidManifest.xml<\/em> file to your <em>\/app\/App_Resources\/Android\/<\/em> folder.\u00a0\u00a0 This is going to be your primary manifest and the one you will edit to your hearts desire.\u00a0 Make sure you <strong>COPY<\/strong> just your app manifest.<\/p>\n<p>Next you will need to edit the <em>\/platforms\/android\/src\/main\/AndroidManifest.xml<\/em> and basically deleted everything in it.\u00a0\u00a0 This file should end up looking like this:<\/p>\n<p>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;<br \/>\n&lt;manifest\u00a0 xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"<br \/>\npackage=\"<strong>YOUR_APP_PACKAGE<\/strong>\" &gt;<br \/>\n&lt;\/manifest&gt;<\/p>\n<p>Do not copy the above as is; you need to make sure the \"<strong>package<\/strong>\" property contains your app package name, which is why I recommend you edit the one in their as it already has your app package in it.\u00a0 If you copy the example above, it has <strong>YOUR_APP_PACKAGE<\/strong> which is an invalid package name.<\/p>\n<p>Because the manifests are merged; and since the package name doesn't change the merging system is able to merge everything in your brand new App_Resources\/Android\/AndroidManifest.xml into the original AndroidManifest.xml file without any conflicts!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So here I was again minding my own business on the forums again, and Ben posted he had been attempting to use this new feature of v1.5.x of NativeScript and it was failing.\u00a0 I responded it didn't work like that.\u00a0\u00a0 Thankfully he was persistent and ignored my wrong response, and linked to the github issue&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=208\">Continue reading <span class=\"screen-reader-text\">NativeScript: Keeping your AndroidManifest.xml easily editable and under version control.<\/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,39],"tags":[],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-javascript","category-nativescript","category-tips","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=208"}],"version-history":[{"count":2,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}