Test Debug Version on Virtual or Physical Devices (Windows/Mac)

To emulate physical devices, you can use Android Studio emulator to create virtual devices. When Android Studio was installed it created a virtual device using the latest version of Android by default. You can use the Android Virtual Device (AVD) Manage to SEE what virtual devices you currently have or CREATE new ones.

  1. To view virtual device(s), go to Tools > Android > AVD Manager or click on the AVD Manager icon ) at the top of the screen.
  2. In the Your Virtual Devices window that appears, you will see a default device (e.g., Nexus) listed and any other virtual devices that you have created earlier.


  3. (Optional) If you want to start with a fresh copy of a virtual device, select it and then click on the down arrow on the right and select Wide Data and in the Confirm Data Wipe dialog box that appears, click the Yes button.

To run virtual device,

  1. Click the Start button icon (  ) the right side of the screen.
    NOTE: It may take a while for the AVD to load. When you click the Play button, Android Studio will start Gradle-build and then prompt you to select a virtual or real device from the list.
  2. If you see the Welcome message, press GOT IT. If you want to get rid of these notification, swipe down and then swipe right for each notifications.
  3. Once the virtual device is up and running, drag the lock icon upward to unlock the device.
  4. Click the icon to show all of your apps.


  5. Click the home button to go back to the home screen.


  6. Return to Android Studio and press SHIFT+F10 or click the Run button ) at the top of the screen.
  7. In the Choose a running device dialog box that appears, select a device.
  8. Click the OK button.
  9. Click ALT+TAB on Windows, or CMD+TAB on MAC to bring device to the front of the screen and then you should see your app on your device.
    TIP: To toggle the orientation from portrait to landscape and back again, click the CTRL+F11 on the PC or Mac. It is also good practice to keep the device open, change the code and then run again to avoid having to wait for the virtual device to open again.

New Features in Android Studio Emulator 2.0

(Optional) Create New Virtual Device

You can create as many virtual devices as you need to test your app to emulate physical (real) devices.

  1. Close any existing virtual devices to free up memory.
  2. Open the AVD Manager by selecting Tools > Android > AVD Manager or click on the AVD Manager icon (  ) at the top of the screen.
  3. Click the Create Virtual Device button at the bottom of the window (See screenshot above).
    NOTE: You can choose from any of the form factor (TV, Phone, Tablet, Wear and Glasses) to create a device.
  4. From the category list on the left side of the window, choose a form factor (e.g., Phone)
  5. Select a target device from the list (e.g., Nexus 6),
  6. (Optional) Click the New Hardware Profile button if you want to make any changes and then click the OK button.
    ALTERNATIVE: You can click the Clone Device... button and then make necessary changes to create a new virtual device.
  7. Click the Next button.


  8. In the System Image dialog box that appears select a system image (Android version) (e.g., Marshmallow).


  9. Click the Next button.
  10. (Optional) In the Verify Configuration dialog box that appears, if you have enough memory, click the Show Advanced Settings button and scroll down and reduce the amount of RAM (e.g., 1G) that the device uses so the multiple devices can run at the same time.
    EXAMPLE: If you have a lot of memory, you may want to set HAXM to 3G and each AVD to 1G. It is also a good idea to increase the VM-Heap to 256 to avoid errors with some apps and check the Enable Keyboard input checkbox to allow typing with computer's keyboard instead of on-screen virtual device keyboard.


  11. Click the Finish button to create the device.
  12. Close the AVD manager and all other virtual devices and then click on the Run button at the top of the screen to run the app.
    NOTE: Notice this time you are starting the app not the device first.
  13. In the Choose Device dialog box that appears, choose Launch Emulator radio button instead of Choose running device radio button, then choose a new device from the drop-down list and then click the OK button.
    NOTE: You should see the run window and the console panel and then the device should start up.
  14. When the lock screen appears, drag the lock icon upward.
  15. CHECK POINT: Click the OK button to any messages you see and the app should appear.

(Optional) To run on more than one device:

  1. Click the Back button on the device to return to the home screen.
  2. Return to Android Studio and open the AVD manager and choose another virtual device (e.g., Nexus 5) and click the Start button.
  3. Repeat step 2 for as many devices as you need.
  4. Arrange devices on the screen by dragging them next to each other.
  5. Once the lock screen appears on the other devices,drag the lock icon upward.
  6. Return back to Android Studio and click the Run button again.
  7. To run the app simultaneously on two or more devices, hold down the SHIFT key and click to select multiple devices and then click the OK button.
  8. CHECK POINT: Go back to the two devices to see the app runs on all devices.

Sideload App

Another way to load an app is to side-load it where you bypass an app store and send the app's apk directly to the device. This can be done by various means:

  1. Email app
  2. File share app (e.g., Dropbox) or file transfer (AirDroid)
  3. Download app from website

However, an Android device have to have its security setting changed to allow apps from unknown sources which is not turned on by default. (See Prep for Android menu option for details). Once this setting has been changed, the app can be installed onto a device.

You can also download an app to your computer and then install it on your device if you don't have a QR Reader.

  1. Click the Download icon from PhoneGap Build to download a copy of the app to your device.
  2. Connect your phone or tablet to your computer.
  3. Navigate to the apk file (e.g., myAppName-debug.apk) and copy it.
  4. Paste the *.apk file to the apps folder on your device (e.g., Android > Android-sdk > Platform tools).
  5. Open the Android SDK Manager and then select Tools > Managed AVDs
  6. Select an Android Virtual Device and then click the Start... button.


  7. Open a Command Line Interface (CLI) (e.g., Terminal on the Mac and Command Prompt on Windows) and navigate to the directory where the Android SDK is (e.g., cd platform-tools)

    NOTE: On a Mac, type ls first then cd...

  8. Type ./adb install myAppName-debug.apk (where myAppName-debug.apk is the actual name of the apk).

    WHY: To install app on virtual device.

  9. Press the Enter or Return Key.
  10. CHECK POINT: You should see the word Success appear.
  11. Switch back to the emulator and click the App icon:


  12. Once the app screen opens, click the app icon.
  13. CHECK POINT: You should see your app opens


  14. Test the app in the emulator.

    NOTES:
    - You could also copy the apk to a dropbox folder and sync it. Select the apk file and install it.
    - If you were to change the *.apk extension to *.zip, you would be able to see the additional files that PhoneGap Build created for the app by unzipping the file and examining the files and folders:

    -
    an app manifest (an XML file that describes the app's version, capabilities and permissions)
    -
    a signed certificate (that verifies the identity of the developer).
    - custom compiled classes

    - app's resources, graphics and other files (compiled or uncompiled).

    All of these files and folders are compressed during the packaging process into the single APK file.