{"id":5227,"date":"2018-07-02T17:20:05","date_gmt":"2018-07-02T13:20:05","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/ubuntu-apache-cordova\/"},"modified":"2018-07-02T17:20:05","modified_gmt":"2018-07-02T13:20:05","slug":"how-to-install-apache-cordova-on-ubuntu-18-04-lts","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-apache-cordova-on-ubuntu-18-04-lts\/","title":{"rendered":"How to Install Apache Cordova on Ubuntu 18.04 LTS"},"content":{"rendered":"<p>Apache Cordova (Formerly known as PhoneGap) is a free and an open source mobile development framework that can be used to build applications for mobile devices using CSS3, HTML5, and JavaScript. You can build hybrid mobile applications using HTML, CSS, and JavaScript in Cordova platform that will be used on different mobile platforms like, IOS, Android, Windows. Cordova is faster to develop hybrid app then native app, so it can save your development time.<\/p>\n<p>In this tutorial, we will learn how to install Cordova on Ubuntu 18.04 LTS (Bionic Beaver).<\/p>\n<h2 id=\"requirements\">Requirements<\/h2>\n<ul>\n<li>A server running Ubuntu 18.04 to your system.<\/li>\n<li>A non-root user with sudo privileges.<\/li>\n<\/ul>\n<h2 id=\"install-nodejs\">Install Node.js<\/h2>\n<p>First, you will need to install the latest version of Node.js to your system. By default, the latest version of Node.js is not available in Ubuntu 18.04 default repository. So, you will need to add PPA for node.js to your system.<\/p>\n<p>You can do this with the following command:<\/p>\n<p class=\"command\">sudo apt-get install python-software-properties -y<br \/>curl -sL https:\/\/deb.nodesource.com\/setup_8.x | sudo -E bash &#8211;<\/p>\n<p>Once the repository is installed, install Node.js using the following command:<\/p>\n<p class=\"command\">sudo apt-get install nodejs -y<\/p>\n<h2 id=\"install-cordova\">Install Cordova<\/h2>\n<p>Now, install Cordova using the npm command as below:<\/p>\n<p class=\"command\">sudo npm install -g cordova<\/p>\n<p>Output:<\/p>\n<pre>\/usr\/bin\/cordova -&gt; \/usr\/lib\/node_modules\/cordova\/bin\/cordova&#13;\n+ <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"12717d60767d6473522a3c223c22\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#13;\nupdated 1 package in 15.829s&#13;\n<\/pre>\n<p>Once the Cordova is installed, you can check the version using the following command:<\/p>\n<p class=\"command\">cordova &#8211;version<\/p>\n<p>Output:<\/p>\n<pre>? May Cordova anonymously report usage statistics to improve the tool over time? Yes&#13;\n&#13;\nThanks for opting into telemetry to help us improve cordova.&#13;\n&#13;\n8.0.0&#13;\n<\/pre>\n<h2 id=\"create-your-first-app\">Create Your First App<\/h2>\n<p>Cordova is now installed, it&#8217;s time to create an app using Cordova.<\/p>\n<p>Run the following command to create your first app with name TestApp:<\/p>\n<p class=\"command\">cordova create TestApp<\/p>\n<p>Output:<\/p>\n<pre>Creating a new cordova project.&#13;\n<\/pre>\n<p>Next, change the directory to the TestApp and add the required platform in your application.<\/p>\n<p class=\"command\">cd TestApp<br \/>cordova platform add android<\/p>\n<p>You should see the following output:<\/p>\n<pre>Using cordova-fetch for <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"26454954424950470b47484254494f4266\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>~7.0.0&#13;\nAdding android project...&#13;\nCreating Cordova project for the Android platform:&#13; Path: platforms\/android&#13; Package: io.cordova.hellocordova&#13; Name: HelloCordova&#13; Activity: MainActivity&#13; Android target: android-26&#13;\nSubproject Path: CordovaLib&#13;\nSubproject Path: app&#13;\nAndroid project created with <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"abc8c4d9cfc4ddca86cac5cfd9c4c2cfeb9c859b859b\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#13;\nAndroid Studio project detected&#13;\nAndroid Studio project detected&#13;\nDiscovered plugin \"cordova-plugin-whitelist\" in config.xml. Adding it to the project&#13;\nInstalling \"cordova-plugin-whitelist\" for android&#13;\n&#13; This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.&#13; &#13;\nAdding cordova-plugin-whitelist to package.json&#13;\nSaved plugin info for \"cordova-plugin-whitelist\" to config.xml&#13;\n--save flag or autosave detected&#13;\nSaving <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"eb8a858f9984828fab\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>~7.0.0 into config.xml file ...&#13;\n<\/pre>\n<p>Next, run the following command to list the installed and available platforms for Cordova application.<\/p>\n<p class=\"command\">cordova platform -ls<\/p>\n<p>Output:<\/p>\n<pre>Installed platforms:&#13; android 7.0.0&#13;\nAvailable platforms: &#13; browser ~5.0.1&#13; ios ~4.5.4&#13; osx ~4.0.1&#13; windows ~5.0.0&#13; www ^3.12.0&#13;\n<\/pre>\n<p>If you want to remove any platform, you can remove it by just running the following command:<\/p>\n<p class=\"command\">cordova platform remove android<\/p>\n<p>Next, you will need to fulfill all the requirements for your build environment. You can do this by running the following command:<\/p>\n<p class=\"command\">cordova requirements<\/p>\n<p>Once all the required dependencies are installed successfully, run the following command to build your application:<\/p>\n<p class=\"command\">cordova build android<\/p>\n<h2 id=\"links\">Links<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-apache-cordova%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-apache-cordova-on-ubuntu-18-04-lts.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-apache-cordova%2F&amp;text=How+to+Install+Apache+Cordova+on+Ubuntu+18.04+LTS&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-apache-cordova-on-ubuntu-18-04-lts-1.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-apache-cordova-on-ubuntu-18-04-lts-2.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fubuntu-apache-cordova%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/how-to-install-apache-cordova-on-ubuntu-18-04-lts-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Apache Cordova (Formerly known as PhoneGap) is a free and an open source mobile development framework that can be used to build applications for mobile devices using CSS3, HTML5, and JavaScript. You can build hybrid mobile applications using HTML, CSS, and JavaScript in Cordova platform that will be used on different mobile platforms like, IOS, &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-5227","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=5227"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5227\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=5227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=5227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=5227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}