@towfiqpiah wrote:
As Ionic depends on cordova, you need to install it first. To install Cordova, make sure you have Node.js installed. Following step by step guide shows what to do to install ionic so that you can build your brand new ionic app right away. This guide is intentionally made precise rather explaining much stuffs. Lets get going!
Install node.js (v4)
If you don’t have cURL installed, install it first:
sudo apt-get install php5-curlNow run following commands:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash –sudo apt-get install -y nodejsTo compile and install native addons from npm you may also need to install build tools: (optional)
sudo apt-get install -y build-essentialInstall cordova:
After successful nodejs installation, now you need to install cordova to access cordova library when you need them.
sudo npm install -g cordovaIf you are running a 64-bit version of Ubuntu, you'll need to install the 32-bit libraries since Android is only 32-bit at the moment.
sudo apt-get install ia32-libsIf you are on Ubuntu 13.04 or greater, ia32-libs has been removed. You can use the following packages instead:
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0Install Ionic:
Ionic comes with a convenient command line utility to start, build, and package Ionic apps. To install it, simply run:
sudo npm install -g ionicIf you've come this far, you’ve successfully installed Ionic on your system. Now lets create a brand new app!
Create the project:
Now, its the time to create a new Cordova project:
ionic start todo blankIf you get Error: Cannot find module 'xmlbuilder', follow this step:
* Remove nodejs
* Delete the /usr/lib/node_modules (/usr/local/lib/node_modules) folder
* Reinstall nodejs
* Clear the npm cache (npm cache clean)
* Reinstalling ionicRun app with a browser:
Go to your project root and run:
ionic serveThis will run demo app on your browser. While app is running, you can use following commands to do specific tasks needed:
- restart or r to restart the client app from the root
- goto or g and a url to have the app navigate to the given url
- consolelogs or c to enable/disable console log output
- serverlogs or s to enable/disable server log output
- quit or q to shutdown the server and exit
If you are ok with web view of your app, then you're done. Above steps are all you needed. But if you want to test your app on emulator/real device, keep moving..
Install Android Studio to work for android:
Make sure you’ve Oracle JDK 8 installed in your system ( http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html ). Download and install android SDK from official site: http://developer.android.com/sdk/index.html
While installing (downloading), if you get this error:
Unable to run mksdcard SDK tool. One common reason for this is missing 32 bit compatibility libraries. Please fix the underlying issue and retry, run this command and retry downloading:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1Now set ANDROID_HOME and point it to Sdk folder. Then update PATH variable so that you can user android command from terminal. Follow either steps below:
[Temporary] Open terminal and run these commands:
export ANDROID_HOME=”$HOME/Android/Sdk”export PATH=”$PATH:$ANDROID_HOME/tools”export PATH=”$PATH:$ANDROID_HOME/platform-tools”[Permanent] Open terminal and run this:
gedit ~./profileAdd these lines to the bottom and save:
export ANDROID_HOME=”$HOME/Android/Sdk”export PATH=”$PATH:$ANDROID_HOME/tools”export PATH=”$PATH:$ANDROID_HOME/platform-tools”Logout and login again. This will make android command available from terminal. If you don't have .profile in home, run this and configure according to instruction. .profile will be created:
sudo passwd rootRun the app with an emulator:
Now, you need to tell ionic that you want to enable the iOS and Android platforms. Note: unless you are on MacOS, leave out the iOS platform:
ionic platform add androidionic platform add iosYou’ll get this warning upon trying to add ios platform from linux machine: WARNING: Applications for platform ios can not be built on this OS - linux. To make local android build on application, run this command:
ionic build androidAfter successful build, you can now emulate your app. If you've properly configured AVD, you'll see your app running on emulator in a while. For that, run following command:
ionic emulate androidIf you get Error sh: 1 glxinfo not found in any stage of emulation, run following command to fix this:
sudo apt-get install mesa-utilsAfter BUILD is successfull, you'll be able to emulate your app on emulator. To run your awesome app on real android device, just set debug mode 'on' from developer option, connect it to your pc and run following command:
ionic run androidTa Da! Your app is running on your phone !!! Congratulations
![]()
[Source] CodeBlog: http://blog.towfiqpiash.com/install-ionic-on-ubuntu-14-04/
Posts: 1
Participants: 1