paint-brush
How to run IONIC application in android using ubuntu?by@hackernoon-archives
1,698 reads
1,698 reads

How to run IONIC application in android using ubuntu?

by HackerNoon ArchivesJuly 11th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Testing your app in the browser with ionic serve or with an emulator is fast, easy and convenient when your app is in <a href="https://www.thirdrocktechkno.com/mobile-app.html">development</a>, but eventually you’re going to have to test on a device. Not only is it the only way to accurately test how your app will behave and perform, many <a href="http://ionicframework.com/docs//native/">Ionic Native</a> plugins will only work when they are run on actual hardware.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to run IONIC application in android using ubuntu?
HackerNoon Archives HackerNoon profile picture

Testing your app in the browser with ionic serve or with an emulator is fast, easy and convenient when your app is in development, but eventually you’re going to have to test on a device. Not only is it the only way to accurately test how your app will behave and perform, many Ionic Native plugins will only work when they are run on actual hardware.

To test hardware related plugins we must have to run our application in real android device.To run an ionic application in android device using ubuntu system follow below steps.

Requirements

  1. Java JDK
  2. Gradle
  3. Android Studio or SDK Tools (https://developer.android.com/studio/index.html)

Install Java

Run the following command to install JDK 8 on your system.

sudo apt-get install openjdk-8-jdk

Verify the installation.

java -version

Download Gradle

Run the following commands to download Gradle to your system.

sudo apt-get install wget unzip

Then

wget https://services.gradle.org/distributions/gradle-3.4.1-bin.zip

You can always check the Gradle release page to look for the link to the latest version of Gradle.

Install Gradle

Create a directory for the Gradle installation.

sudo mkdir /opt/gradle

Extract the downloaded archive to the newly created directory.

sudo unzip -d /opt/gradle gradle-3.4.1-bin.zip

Configure the PATH environment variable so that the executable file of gradle can be directly executed anywhere on the system.Or if you want to install it permanently put below line in your ~/.bashrc file which is in your home directory to see that file press Ctrl+h in your directory.

export PATH=$PATH:/opt/gradle/gradle-3.4.1/bin

You can run the following command to check if the Gradle install was successful.

gradle -v

The installation is complete. Your system is now ready to build programs using Gradle.

Android Studio or SDK Tools ( https://developer.android.com/studio/index.html )

  • After you have downloaded SDK tools you have to set android home path in your machine. For that in the console just type these (remember to change to your current location)

  • export ANDROID_HOME=$HOME/your sdk pathexport PATH=$PATH:$ANDROID_HOME/tools

If you want to make it permanent just add those lines in the /.bashrc file.

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run following from the command line.

ionic cordova run android --device

Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search. You can also check out Enabling On-device Developer Options in the Android docs.

Now above command can inject your android app in your device which you can test directly from the device.