22 - Test and Install Mobile Apps on Real Devices

Introduction

We have developed more than a dozen of apps by now. We have tested all these apps either on iOS simulator or on Android emulator. Of course, we can identify the errors and issues in our code by testing the app on a virtual device itself. But if we want to get the actual feel of our app, we need to test it on a real device. Is it actually possible? In fact, if you want to install and test am iOS mobile app on a real device or plan to publish your app on the App store, you need to have a) an iOS device like iPhone or iPad of course b) an iOS developer certificate. You can buy the certificate from developer.apple.com. The happy news is that you need only an Android phone to test the Android mobile app. In this tutorial, we are going to see how to test an app on a real Android device.

Connect to the Android Device

First connect the Android phone to your Mac through USB. In the Android phone, go to Settings à Develop Option and enable USB debugging. Make sure that the connection type is set to "Charge only" and not "Internet pass-through". Otherwise, you might not be able to test the app.

You can test any Android app on the device. Suppose you want to test the app AndroidTrackLocation that we have developed in the Geolocation chapter. Now open the project in the Android Development Environment (Eclipse). Run the project as usual and you will get a screen to choose the device to test the project. The screen will display the names of all the virtual devices along with the name of your Android phone. Choose the Android phone and click the Run button.

Now, you will see the output in your mobile screen. If you click the back button, you will find the name of our app, here AndroidTrackLocation along with the other apps installed on your phone. Yes, we have tested and installed the app on an Android device.

Now if you visit the project folder on your Mac device, you will find a .apk file inside the bin folder. The application package file (.apk) is the file format used to install the app on an Android operating system. If you want to distribute and install your app on another Android mobile device, you just need to copy the .apk file in the project's bin folder and then install it to the phone. Now your app is ready to use.

A Simple Tip for Faster Development and Testing

By now you might have realized that testing a mobile app on an iOS simulator is lot faster than testing it on an Android emulator. Of course, you will have to test your app multiple times before it becomes ready. Suppose you want to develop an Android app. The simple and easy tip is that develop an iPhone app for the same purpose. Code the index.html file to accomplish your requirements. Test it on the iOS simulator as many times as you want and make sure that it works the way you want. Then create an Android application. Delete the index.html file in the assets/www folder. Just copy the index.html file from the www folder in your iOS project folder and paste it inside the assets/www folder of your Android project folder. Open the Android project in Eclipse and run it. Now you are ready with the app.

Do not forget to copy and paste other .html, .css or .js files if any. If you have separated the syle or script from the main index.html page, then you could have .js and .css files. Also, if your app is a multi screen app, then you will have other .html files in addition to index.html file. So, while copying the files, you need to make sure that you copy all of them and place them in the correct folders.

Summary

In this tutorial, we have seen how to install and test an Android app on a real physical device. You could also distribute the app to as many Android devices you want using the .apk file. We have also seen a simple technique that makes the app development and testing faster.

Like us on Facebook