Android Emulator Mac Cordova

-->

You've created an Apache Cordova application project using Visual Studio and Visual Studio Tools for Apache Cordova (TACO), and now you're ready to test it. Fortunately, you have several options for running your Cordova apps on Android using Visual Studio:

  • Android device - jump to details
  • Cordova Simulate (simulate in browser) - jump to external article
  • Google Android Emulator - jump to details
  • Genymotion Emulator - jump to details

In this article, you'll learn how to use these options to run your Android apps in Visual Studio.

Cordova prepare. This creates the mfpclient.properties file in the assets folder. If this file does not exist, you cannot run your app. Open the project in Android Studio. From Android Studio select File-New-Import Project. Navigate to the build.gradle file in project name and click OK. In the project navigator pane the project looks like this.

Throughout the steps outlined below, if you have trouble deploying to Android devices or emulators, be sure to check out Resolve Android build and deployment errors.

To deploy a Release or Distribution configuration of your app, you must sign your app first. For more information, see Package your App.

Run on an Android Device

To run your Android app on an Android device in Visual Studio, complete the following steps:

  1. Connect the Android device to your development system using the appropriate USB cable for your device (most Android devices use a Micro-USB cable, but newer devices may use the newer USB-C type connector).

    You should hear Windows beep to indicate that it recognizes a new connected device. Any required device drivers should load automatically.

  2. Check to see that USB debugging is enabled on the device. Pull down from the top of the home page to view the list of notifications, you should see an indicator that USB debugging is enabled as shown in the following figure:

    If USB debugging is disabled, open Settings and look for Developer options as shown below:

    Note

    You may have to execute some complicated process to enable developer options; for this particlular device, for example, developers have to open Settings, select About phone, then tap Build number repeatedly until the OS enables developer mode.

    Open Developer options and scroll down until you find Debugging options as shown in the figure. Enable USB debugging as shown in the figure and any other settings you think might help the debugging process.

  3. Make sure that the Android Debug Bridge (ADB) sees the device. To do this, open a Command Prompt and execute the following command:

    By default, Visual Studio TACO installs the Android SDK in C:Program Files (x86)Androidandroid-sdk, so for the standard installation, you would execute:

    Note

    We added quotes around the executable filepath because there are spaces in the path.

    ADB will report any connected devices as shown in the following example:

    If ADB doesn't see any devices, then you must resolve the issue before continuing. Double-check to make sure Windows Device Manager sees the device, try a different cable, try a different USB port, ect.

  4. In the Visual Studio Standard toolbar, set the release type to Debug, the target OS to Android, and the debug target to Device as shown in the following figure. Click the Device button, or press F5 to build and launch the application, and then begin a debugging session with the application.

    Visual Studio will build the Android version of the Cordova application (using the Cordova CLI and Android SDK), then deploy the app to the connected device and launch it. Next, Visual Studio opens the DOM Explorer to enable you to interact with the application as it runs.

Run on the Google Android Emulator

The Google Android Emulators deliver a software-only solution for testing your Android applications. These emulators deliver most of the functionality available in a physical device except that sensors and other hardware components may not work or will work in a simulated manner. In this section, you'll learn how to use Google's Android emulators to run your Apache Cordova application.

When you installed TACO, you had an option to install the Google Android Emulators as shown in the following figure:

If you did not enable the highlighted options, close Visual Studio, launch the Visual Studio Installer and modify the installation to include these options. You can tell whether the emulators are installed or not by opening Visual Studio's debug target list, if you see Install Android build tools.. in the list, instead of some Android emulators, then you need to complete the installation.

Select the installation option in the drop-down, then click the button (shown below) to begin the installation.

Android emulators are defined using the Android Virtual Device (AVD) Manager, you can learn how to create and manage Android virtual devices here. The Visual Studio TACO installation process creates several virtual devices for you automatically during installation; you can confirm this using the Android SDK's AVD Manager application:

As you can see, Visual Studio creates two phone and two tablet emulator configurations. The difference is in the processor architecture selected for the emulator. The Intel emulators launch fairly quickly and perform better than the ARM emulators. Unfortunately, the Intel emulators require a specific hardware configuration that we'll discuss in a minute. For that reason, you'll see these emulators represented in Visual Studio through the following menu:

When you select one of these emulator options, Visual Studio will launch the right emulator configuration based on your system's hardware configuration. If your system supports the Intel emulators, those emulators will be used by default. If not, Visual Studio will automatically fallback to using the ARM emulators instead.

You can configure Visual Studio's behavior here. In Visual Studio, select Tools -> Options. Expand the Tools for Apache Cordova option and select Android Emulator. The detection option will be selected by default, to disable detection and use the ARM emulators by default every time, select the No detection option.

To run your Apache Cordova application on an Android Emulator: in the Visual Studio Standard toolbar, set the release type to Debug, the target OS to Android, and the debug target to one of the Google Emulator options as shown in the following figure. Click the Google Emulator button, or press F5 to build and launch the application, and then begin a debugging session with the application.

Mac

Configuring Your System to Use HAXM

By default, the Google Android emulator uses Intel's HAXM virtualization technology to improve the performance of the emulators. HAXM requires you to use an Intel processor that supports Intel's VT-x technology; to learn if your processor is supported, check out Determine If Your Processor Supports Intel Virtualization Technology. When running on an Android emulator, Visual Studio attempts to first use a HAXM enabled emulator. If HAXM is not installed, or cannot be used on your computer, then a slower ARM-based emulator image is used.

If you find that the Google Android Emulator is performing slowly, try disabling Hyper-V. HAXM is incompatible with Microsoft's Hyper-V technology, so to use them, you'll need to disable Hyper-V. You can disable Hyper-V through the Windows Control Panel or using the Windows command-line using the instructions in the following sections.

Note

Disabling Hyper-V will prevent you from using the Windows Phone emulator. However, you can still deploy to a Windows Phone device while Hyper-V is disabled.

To disable Hyper-V in Control Panel

  1. In the Control Panel, choose Programs and Features, and then choose Turn Windows features on or off.

  2. Clear the check box for Hyper-V.

  3. Reboot your PC.

    Alternatively, you can configure Windows to start with Hyper-V automatically enabled or disabled using the command line.

To disable Hyper-V using the command line

  1. Open an elevated command prompt (with administrative credentials), and type:

    Warning

    The bcdedit commands can prevent your system from booting if not executed correctly; be careful when using these commands.

  2. Reboot your PC. If you want to re-enable Hyper-V later, use the following command, and then reboot your PC:

Run on the Genymotion Emulator

The Genymotion emulator is a commercial offering and a popular alternative to the Google Android emulator. Follow Genymotion's instructions to install the emulator. Here are a few tips for getting started with the emulator:

  • If you have trouble starting the emulator from a remote connection, try starting it locally, and then reconnect remotely if needed. The emulator requires OpenGL for rendering, and this may result in a conflict when starting the emulator.
  • You need a video card and video card drivers that support OpenGL. You may receive messages that indicate this. (If you connect to your PC remotely, you may also see this message. Try again after connecting locally).
  • You may receive a message to check your VirtualBox network configuration when you try to start the emulator. Follow the link and instructions to modify or remove the Host-only Network Adapter from VirtualBox. (VirtualBox is included with the installation of the emulator).
  • For high-performance emulation using Genymotion, disable Hyper-V before starting the emulator, as described earlier in Configurig Your System to Use the Intel Emulators. Android developer tools see Genymotion as a physical device. When you use Visual Studio to run the app, you instruct Visual Studio to deploy to an Android device.

To run your app on the Genymotion emulator, complete the following steps:

  1. Start the Genymotion emulator.

  2. The emulator looks like a physical device to the Android SDK (and therefore Visual Studio). Make sure that the Android Debug Bridge (ADB) sees the Genymotion emulator as a device. To do this, open a Command Prompt and execute the following command:

    By default, Visual Studio TACO installs the Android SDK in C:Program Files (x86)Androidandroid-sdk, so for the standard installation, you would execute:

    Note

    We added quotes around the executable filepath because there are spaces in the path.

    ADB will report all connected devices, and the Genymotion emulator should be listed.

  3. In the Visual Studio Standard toolbar, set the release type to Debug, the target OS to Android, and the debug target to Device as shown in the following figure. Click the Device button, or press F5 to build and launch the application, and then begin a debugging session with the application.

See Also

The Cordova is a platform to build Native Mobile Applicatons using HTML5, CSS and Java Script. Cordova is tipically used from the command-line runs on Node.js and is available on NPM. Technically the User Interface of a Cordova Application is effectively a WebView that occupies the entire screen and runs in a native Container. So, it is the same web view that is used by the Native Operating systems (i.e the default browser). With Cordova we can, through a web application built by you and contained by the web view of cordova, access native functionalities of the Mobile Operative System (like dialogs, the filesystem, the camera etc) with Javascript through the famous plugins of Cordova.

In this article, you are going to learn how to implement from scratch a cordova application in a Windows Environment and how to deploy your app in an Android Device.

1. Install required tools

You will need to install 3 tools in order to create your first cordova app in Windows:

  1. Java Development Kit (JDK): we need the development kit of Java installed in our computer.
  2. Android Studio and the Android SDK: although we won't use Android Studio, is recommendable to download the full package that includes Android Studio and the SDK, this SDK includes the build tools, AVD Manager and the SDK Manager. The installation filesize is about 1.6 GB.
  3. Node.js for Windows: download a pre-built installer for your platform of Node.js with the architecture of your system (x64 or x86). The installer can be either MSI or a EXE file.

As the installation of each of these tools doesn't need any special configuration but only to follow the installation wizard in the system, take care of the installation and proceed to the step 2 when everything has been installed. If you want to verify if everything was correctly installed, you can check the installation directories:

JDK Installation

Locate the folder of installation (that is usually ) and check that the jdk[version] folder exists:

Besides, the JAVA_HOME environment variable needs to exists. In case that it wasn't automatically created, you'll need to create it. Once you have the JDK installation path (with /bin at the end):

  1. Right-click the My Computer icon on your desktop and select Properties.
  2. Click the Advanced tab, then click the Environment Variables button.
  3. Under System Variables, click New.
  4. Enter the variable name as JAVA_HOME.
  5. Enter the variable value as the installation path for the Java Development Kit (in this example would be C:Program FilesJavajdk1.8.0_111bin).
  6. Click OK.
  7. Click Apply Changes.

Android SDK

Open the AppData folder typing %appdata% in the windows search bar or by pressing WIN + R:

Navigate then into the Local folder and then the android folder should exist and inside should be located the sdk folder, the sdk folder should have the following content (or similary):

Node.js

To check if node.js was correctly installed, there should be a direct access named Node.js Command Prompt executable in the start menu:

This executable is the same cmd.exe of windows, however it runs the following command to start : C:WindowsSystem32cmd.exe /k 'C:Program Filesnodejsnodevars.bat'. Therefore if the executable for some extraordinary reason, you can execute the previous command to start in a cmd window. The Node console should look like:

In this console you will run every node and cordova command later.

Windows longhorn build 5048 iso. This Is Windows Longhorn Build 5048 Witch Is A New Beta Of Windows Vista Longhorn Bios Date No Product Key TCP8W-T8PQJ-WWRRH-QH76C-99FBW Addeddate 2020-02-27 06:28:41. ISO IMAGE download. Download 1 file. ITEM TILE download. Download 1 file. This Video Teach You How To Install Windows Longhorn Build 5048 On Virtual Box Link Download: MS - DOS 7.1 Iso: https://winworldpc.com/download/40c2bd6b-66. Longhorn Build 5048 This is the installation guide to install Windows Codename Longhorn build 5048 and correctly activate DWM in VMware or on a real computer. The information and walkthrough is provided in a tutorial video to the left, though if you prefer a written tutorial, please continue reading. Microsoft Windows Longhorn is initially operated under the tag of Windows XP and considerably known as Microsoft Vista. The free download is believed to be a standalone ISO installer with access to both 32 bit and 62-bit architecture. Windows Longhorn Build 5048 Iso. Windows Longhorn Build 5048 Iso A typical build label would look like. The lab in which any given build originated is shown as part of the build label, and the date and time of the build follows that. Visually it was not significantly different from Windows XP.

2. Install Cordova in Node.js

Proceed with the installation of Cordova executing the following command in the Node.js Command Prompt:

As cordova will be globally installed, you can execute the command from wherever you are in the console. Once the installation has been completed, verify the version of cordova executing:

That should generate the following output in the console (note that the cordova version may vary):

3. Create your first project

Now that the cordova CLI is available for its usage, we can start with the creation of our project. Navigate with the console to a folder where you want to store all your cordova projects using the CD command, in this case the folder will be located in the Desktop and will have the name dev-desktop:

Proceed with the creation of the project using the cordova create command, this command has the following structure:

In this example, our test app will be sandbox and we'll create it executing the following command (change the package name according to yours):

The creation of the project shouldn't take much time, the command will create a folder with the name sandbox and the content of our cordova project will be inside. Now navigate to the sandbox folder using:

With this instruction, you are located with the console in C:UserssdkcaDesktopdev-desktopsandbox , every cordova command for your project should be executed only when you are located in the folder of your project with the console.

4. Add a platform to your project

Your cordova project has been succesfully created, however it won't run on any platform without any. You can use the cordova platform command to add the first platform to your application, in this case and as said in this article we are going to create our first app to be used in Android, therefore we are going to add the android platform using the following command:

The output in the console will be similar to:

After the installation of the platform, your project structure should be similar to:

Important: as you can see in the image, with the latest version of cordova, the android version target is 24. That means that you need to check that this API version is installed in the SDK Manager of android.

Open the SDK Manager (usually located in the Android SDK folder i.e C:Users<YOUR-USERNAME>AppDataLocalAndroidsdkSDK Manager.exe) and verify which versions are installed:

Thank you for your dedication, dev team. I feel these guys deserve a 5-star review. Rldb installation for mac os.

If the target version isn't installed, proceed to install it and wait till the installation is completed.

5. Build and test

You can deploy your cordova application in 2 ways:

Emulator

To emulate your cordova app in an Android Emulator, you need to configure as first the Emulator. Open the AVD (Android Virtual Device) Manager (usually located in the Android SDK folder i.e C:Users<YOUR-USERNAME>AppDataLocalAndroidsdkAVD Manager.exe) and create a new one in case you don't have any created.

Before continue with the creation of an emulator, we recommend you (better said, you need to) to install the Intel HAXM. This can be automatically installed by the Android SDK manager (C:Users<YOUR-USERNAME>AppDataLocalAndroidsdkSDK Manager.exe):

If you already have the Intel HAXM installed, then you can continue with the creation of a new device with a valid target (an existent API version of Android installed i.e Android API 19 - 4.4.2) and a custom name. The following configuration shows an emulator with Android 7 (API 24), 768MB RAM as recommended in Windows and a low resolution device in order to make it work faster in our computer (or change the resolution if you have an awesome computer).

In case you have a video card, check the Use Host GPU option. Finally click on save to create the emulator, once created start it. Our emulator with Android 7 looks like:

Let the emulator window active and as final step, build the app and set the emulator as target using the following command:

If you execute the command and the emulator is not open, then it will start automatically the default emulator available in the AVD Manager (therefore to boost your development time, let the emulator open :-) ). The build of the app will start and you app should start in the emulator, producing:

Pretty easy, right?

Device

To deploy your app on your device, you'll need (worth the redundancy):

  • A mobile device with Android (obviously with at least the minimum Android Version required by a cordova app, tipically Android 4.1.2 API 16).
  • A USB Compatible cable for your device.

Note: some devices need a driver in order to allow the connection between the device and the computer (for example with the Moto G X1040, you'll need the Motorola drivers installed on your computer). You can try without the driver, but in case that the console persists with the error message 'No devices found' and your device is connected, then install the correct drivers.

Connect the device to your computer with the USB cable and execute the following command to build your app and execute it in the device:

The build process will start and the app will be deployed on your device. Congratulations, you've just created and deployed your first cordova application, we recommend you finally to read the documentation of cordova for more information.

Extras

There are a couple of tips that can make your development experience even better:

Debug your index.html using Chrome

As everybody knows, there's no way to debug a cordova page directly in the device. Although the debug on android application using Android studio (a native android app) is quite easy, debugging on a cordova application can become a big nightmare if you don't have the correct tools. You can use Google Chrome to debug your cordova app in the way you debug a website on the Browser.

Debug native code in Cordova

In case that you are working with native code, in this case with Android to create a plugin or something like that, you can use the ADB utility of the Android SDK to debug. ADB, Android Debug Bridge, is a command-line utility included with Google's Android SDK. ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more.

Happy coding !