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
- Java JDK
- Gradle
- Android Studio or SDK Tools
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
- 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.
Ready to level up your app game? Click now to hire an Ionic developer and craft cutting-edge, responsive apps that stand out.
Now above command can inject your android app in your device which you can test directly from the device.
· · · ·Third Rock Techkno is a leading IT services company. We are a top-ranked web, voice and mobile app development company with over 10 years of experience. Client success forms the core of our value system.
We have expertise in the latest technologies including angular, react native, iOs, Android and more. Third Rock Techkno has developed smart, scalable and innovative solutions for clients across a host of industries.
Our team of dedicated developers combine their knowledge and skills to develop and deliver web and mobile apps that boost business and increase output for our clients.
So, what are you waiting for? Hire Android developer today from Third Rock Techkno to create widely used, simple to complex Android apps at highly competitive rates.