{"id":720,"date":"2019-04-09T07:37:13","date_gmt":"2019-04-09T07:37:13","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=720"},"modified":"2019-04-11T01:14:20","modified_gmt":"2019-04-11T01:14:20","slug":"nativescript-androidx-support-and-plugins","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=720","title":{"rendered":"NativeScript AndroidX support and Plugins"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The next major version of NativeScript  (version 6) will be switching from the <strong>android.support<\/strong> packages to the new <strong>androidx<\/strong> namespace.    This will be a hard break; as you can only use the support api's or androidx api's; but not both.  This is something Google has been implementing for a while; and NativeScript is getting on board to eliminate later issues and give us great support.   The awesome developers at Progress have already created a fork of NativeScript; which you can install to test which uses androidx instead of using the support libraries.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since one of my plugins is affected by the changes; I took a look into what was required to support both the current versions of NativeScript and the new upcoming version of NativeScript.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For any of you who have plugins; this code is what I basically devised.   <\/p>\n\n\n\n<pre>let androidSupport=null;\nif (android.support &amp;&amp; android.support.v4) {\n&nbsp;&nbsp;androidSupport = android.support.v4;\n} else if (global.androidx &amp;&amp; global.androidx.core) {\n&nbsp;&nbsp;androidSupport = global.androidx.core;\n}\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then you can use <strong>androidSupport<\/strong> to access the namespace, and it pretty much works the same as what you would access using <strong>android.support.v4<\/strong> or the new <strong>androidx.core<\/strong> replacement.   Because we used feature detection; this allows us to support both namespaces in the same code base.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So if you have JavaScript or TypeScript code that uses <strong>android.support.*<\/strong> then you can use this technique to make your plugin forwards compatible with the next major version of NativeScript while retaining support for the prior versions. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a list of classses that are being moved from android support to androidx: <a href=\"https:\/\/developer.android.com\/jetpack\/androidx\/migrate\">https:\/\/developer.android.com\/jetpack\/androidx\/migrate<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The next major version of NativeScript (version 6) will be switching from the android.support packages to the new androidx namespace. This will be a hard break; as you can only use the support api's or androidx api's; but not both. This is something Google has been implementing for a while; and NativeScript is getting on&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=720\">Continue reading <span class=\"screen-reader-text\">NativeScript AndroidX support and Plugins<\/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,51,39],"tags":[127,16,34],"class_list":["post-720","post","type-post","status-publish","format-standard","hentry","category-javascript","category-nativescript","category-plugins","category-tips","tag-androidx","tag-nativescript","tag-plugins","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/720","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=720"}],"version-history":[{"count":6,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/720\/revisions"}],"predecessor-version":[{"id":728,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/720\/revisions\/728"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}