Android Studio Setup For Cordova Mac



Document your code

Installing Android Studio (And Android SDK) Android studio helps us with a lot, we will use Android Studio to: Install Android Libraries (also know as SDK), Run the android emulator, push our app to a android device. To be able to build for the Android platform, the Android SDK must be installed on your system. If it's not, you can skip this step and add support for another platform, or simply run the tutorial application in your browser. Make sure the Android SDK and the ant build tool are available on your system. The Android SDK is available here. Join Sahil Malik for an in-depth discussion in this video, Android emulator setup for Mac, part of Developing Cordova Apps with Visual Studio Code and Typescript. Adobe, Android, Cordova, Development, Mobile, PhoneGap. PhoneGap & Android Studio. May 16, 2013 Andrew 33 Comments. Yesterday at GoogleIO. This is the best setup I could come up with which allows me to build and delpoy to both Android and iOS devices without needing Xcode or Eclipse.

Every project on GitHub comes with a version-controlled wiki to give your documentation the high level of care it deserves. It’s easy to create well-maintained, Markdown or rich text documentation alongside your code.

Sign up for free See pricing for teams and enterprises
  • Install Procedure

ORDER MATTERS

Please follow the installation order as it appears.

  • If you encounter issues when editing your path variables, please see this stack overflow post for some good advise as how to prevent this issue.
  1. Download JDK- Java SE Development Kit - Windows x64 - (latest edition) and Install using default options
    1. Add a system variable JAVA_HOME and point it to the directory containing the contents of the JDK (example C:Program FilesJavajdk1.7.0_51)
    2. Add ;%JAVA_HOME%bin; to the Path system variable.
    3. If you have a Proxy Server, note proxy server settings and:
      1. Start --> Type Java Control Panel
      2. General Tab --> Click Network Settings...
      3. Choose the appropriate settings, 'use browser settings' may work for you.
    4. Validate Java Install:
      1. From a command prompt enter the following
      2. You should see something like :
  2. Download Apache Ant and extract to a directory on your computer. (example C:utilant)
    1. Add a system variable ANT_HOME and point it to the directory containing the contents of the ANT directory
    2. Add ;%ANT_HOME%bin; to the Path system variable.
    3. Validate Ant Install:
      1. From a command prompt enter the following
      2. You should see something like :
      3. Troubleshooting: Unable to locate tools.jar (check to see if JAVA_HOME is set properly)
  3. Download Android Studio and Install using default settings.
    1. If you have a Proxy Server, note proxy server settings and open Android Studio:
      1. File --> Settings --> (IDE Settings Section) --> HTTP Proxy
      2. Make the appropriate selection for your environment.
    2. Add a system variable ANDROID_HOME and point it to the directory containing the android sdk that's installed with Android Studio (example: C:UsersjdoeAppDataLocalAndroidandroid-studiosdk)
    3. Add the following to your Path system variable:
      1. ;%ANDROID_HOME%platform-tools;%ANDROID_HOME%tools;
  4. Download Node and Install (if you already have it installed, download and install again to update it)
    1. Clear your NPM cache (this may save some headaches):
    2. If behind a firewall, configure node to speak to the firewall by issuing the following commands:
    3. Validate Node Install:
      1. From a command prompt enter the following
      2. You should see something like :
    4. Update Node & Global Packages
      1. Update Node:
      2. Update Global Packages:
  5. Install Cordova
  6. Install Plugman
    1. If behind a firewall, configure plugman to speak to the firewall by issuing the following commands:

Create a New Android Project

  1. In a command prompt, Navigate to a folder that will hold the project (example: C:MobileApps)
  2. Create a new project:
  3. Navigate to the new project folder:
  4. Add the Android Platform:

Setup Android Emulator

  1. Bring up android config:
  2. In the packages tree, in the open Android x.x.x (APIxx) ...
    1. Select Intel x86 Atom System Image
  3. In the packages tree, in Extras..
    1. Select Intel x86 Emulator Accelerator (HAXM)
  4. Click the Install Packages button
  5. Agree to any dialogs that come up.
  6. While still in the android config, note the SDK Path, open windows explorer and navigate to that directory.
  7. Navigate to extrasintelHardware_Accelerated_Execution_Manager and run IntelHaxm.exe
  8. While still in the android config, choose tools->manage avds, switch to Device Definitions, select one, Click Create AVD, be sure to choose Intel Atom(x86) for CPU/ABI and in emulation options enable Use Host GPU, choose ok and close out..

Don't Open the project in Android Studio!

  1. When pulling from source control, make sure all files are not read only and run clean.bat in platformsandroidcordova and delete any local.properties files in any directories..this may help relieve headaches!!!

Debugging Android Apps

  1. Choose to debug using an emulator or on a device attached to the computer:
    1. Start and deploy to the android emulator:
    2. Debug using attached android device:
  2. See cordova android debug output:
  3. You can use Google Chrome Development tools to remotely inspect and debug javascript running on the device (KitKat +) or in the emulator. This is just wonderful!
    1. Update the java code to enable remote debugging
    2. Start the ADB server:
    3. Open a new chrome window, enter the following url into the addres bar:
Ignore the following:
  1. I'm feeling lazy, this page has most of the steps. Just start with the 'Welcome to Android Studio' screen shot and look at the screenshots, just choose the defaults if there's a mismatch, and you'll be good to go.
Clone this wiki locally
-->

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
Android Studio Setup For Cordova Mac

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

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.

Photo Studio Setup For Portrait Photography

Photography

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.

Best Vocal Studio Setup For Recording

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.

Configuring Your System to Use HAXM

Install Android Studio On Mac

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

Android Studio Download For Mac

  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