Overlook on Android Studio: 2. Running App on Devices

While developing applications with Android Studio, we need to test them to check how it works or any bugs etc. But where to test out put and how. Well.. There is Android Emulator available with Android SDK and you test your application with it. i.e. Virtual Device. Even you can test your app on your Physical Device too.

In the previous chapter we learnt, how to create new project with Android Studio. In this chapter we we learn how we can create virtual device and run application with it. As well as we will learn how to connect physical device to Android Studio on your PC and run application on it.


Topics Covered

Creating Virtual Device


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

With the few steps you can create Virtual Device with Android Studio

Step 1: Open Android Studio
Step 2: Open AVD Manager from the top toolbar of the Android studio.

Overlook on Android Studio

Step 3: Once AVD manager will get opened. Click on “Create Virtual Device” Button.

Overlook on Android Studio

Step 4: Choose Device definition and click next. In my case, I am going to choose Nexus 4 definition.

Overlook on Android Studio

You can create new profile by clicking on New Hardware Profile if you are not ok with existing definitions or import saved definitions too.

Overlook on Android Studio

Step 5: Now choose system image and click next.

system-image

I would like to choose Kitkat x86. Only choose x86 images, If you have installed HAXM(Hardware Accelerated Execution Manager). It accelerate emulator to run faster. To know more about HAXM click here..

Step 6: Now click on “Show Advanced Settings” to view more configuration settings.

Overlook on Android Studio

Step 7: Here you can set RAM size and Internal Storage you want. In my case I am only setting RAM size to 1024MB for device I am creating. Once you done with all settings click on Finish.

Overlook on Android Studio

Once you finish you will see the device is created and now its ready to test application.

Overlook on Android Studio

Running App with Virtual Device


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

To run your application on Virtual device while development time, you just need to click on Run button from the toolbar on top.

Overlook on Android Studio

Once you click on Run button, you will see the dialog box to choose devices.

Overlook on Android Studio

If any Virtual Device is already running on your pc it will show you under Running devices list. Otherwise you can choose device from Android virtual device list to launch emulator and run app on it.

To run application on same device again, enable “Use same device for future launches” option bottom of the dialog box and click OK button.

Once click on OK button you can see the emulator will start launching and run your app. If you emulator is already running and you chosen it from running devices, the application will run on already running virtual device.

Overlook on Android Studio

Running App on Physical Device


Warning: Cannot modify header information - headers already sent by (output started at /home/bajayk/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php:3983) in /home/bajayk/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_wp.class.php on line 220

Before run your app from Android Studio on physical device, you need to do few things.
Make sure your ADB(Android Debugging Bridge) drivers are properly installed on your pc.

Overlook on Android Studio

Step 1: Now connect your device to your PC via USB Cable.
Step 2: Go to Settings>Developer Options and enable USB debugging.

Overlook on Android Studio

Step 3: From the Android Studio run the application.

Overlook on Android Studio

Once you click on Run button the Choose Device dialog will appear. Where you must see your physical device in the list of running device list.

Overlook on Android Studio

Step 4: Choose your device from the list.

And here you can see your application is runting on your phone which you connected to pc via USB Cable.

Overlook on Android Studio

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *