Skip to content

Pro Tips Android

Hardik Mistry edited this page Nov 15, 2018 · 1 revision

Visual Studio on Windows PC or Laptop

Difficulty in running Android app on emulator

This is mostly caused because you may not have Intel HAXM installed or Hyper-V is enabled on your PC or laptop or missing Android SDK Tools or Android SDK Build-tools or Android SDK Platform-tools or Android API version.

Emulator not starting

  1. SDK Path not set correctly.
  • Open Visual Studio, Select Tools menu, Select Options menu, Select Xamarin as option on left (Options window will open, you may need to wait to let it open), on the right you should see Java Development Kit location, Android SDK location and Android NDK location, you can edit the path by clicking on change hyper-link button on right of each option.

  • You can optionally enable detailed error logging by setting Output Verbosity under Xamarin Diagnostics option to Detailed from Normal

  1. Install Intel HAXM (Hardware Accelerated Execution Manager) for Windows requires restart (if Intel HAXM is installed, we suggest you to repair)

  2. If you are developer, chances are you have installed and enabled Hyper-V as service on your PC or laptop, for Android Emulator to work Hyper-V needs to be disabled. requires administrative privilege To disable Hyper-V, open Command Prompt with administrative rights (Right click and select Run As Administrator), type bcdedit /set hypervisorlaunchtype off and hit enter on keyboard. requires restart. You may use bcdedit /set hypervisorlaunchtype auto to enable Hyper-V again. requires restart

  3. Chances are emulator was not installed correctly

  • Open Visual Studio, Select Tools menu, Select Android, Select Android SDK Manager, wait while the SDK manager starts.

  • To be able to run emulator and develop apps successfully, you need to install Android SDK Tools, Android SDK Platform-tools, Android SDK Build-tools and Android APIs.

  • After SDK Manager starts (you will be able to select/de-select below mentioned options using a checkbox on left of each item)

    • Select following Android SDK Build-tools versions (You can see the version in the column on right)

      • 21.1., 23.0., 24.0., 25.0., 26.0.*
    • Select following Android SDK Platform-tools

      • 26
    • Select following Android SDK Tools

      • 25.2.*
    • Select following APIs (You may select your choice of API version as per your need)

      • Android 8.0.0 (API 26)
        • SDK Platform
        • Google APIs Intel x86 Atom System Image
      • Android 7.1.1 (API 25)
        • SDK Platform
        • Google APIs Intel x86 Atom System Image
        • Sources for Android SDK
      • Android 6.0 (API 23)
        • SDK Platform
        • Google APIs Intel x86 Atom System Image
        • Google APIs
        • Sources for Android SDK
      • Android 5.1.1 (API 22)
        • SDK Platform
        • Google APIs Intel x86 Atom System Image
        • Google APIs
        • Sources for Android SDK
      • Android 4.0.3 (API 15)
        • SDK Platform
        • Google APIs Intel x86 Atom System Image
        • Google APIs
        • Sources for Android SDK
    • Select following Extras

      • Android Support Repository
      • Google Play Services
      • Instant Apps Development SDK
      • Google repository
      • Google Play APK Expansion library
      • Google Play Licensing library
      • Google Play Billing library
      • Google USB Driver
      • Google Web Driver
      • Intel Hardware Accelerated Execution Manager (do not select if already shown as installed)
      • Emulator (do not select if already shown as installed)
    • Click Install # packages (# indicates number of packages to be installed as per your selection), next you will have to accept the agreement and wait while respective tools and SDKs are downloaded and gets installed.

App not building or not deploying to emulator or device

  • When installing Visual Studio you may or may not have selected a related API version of Android you are trying to build and run (example: you are trying to build and run an app which targets API version 23 = Android 6.0 and so on, chances are the target or minimum version as configured in your project may not be installed at all)

    • In this case, try Step 4 from previous Pro Tip.
  • An altogether challenge you may face is, you clone a git repository or copy existing solution and you are able to build the solution but the app won't deploy to emulator or device

    • In this case, make sure your solution is open in Visual Studio, select Debug as drop down option (not Debug menu), select Configuration Manager, Configuration Manager will show a tabular structure, look for your .Droid project and check if the checkbox under Deploy column is selected, if not select it, then retry to build and deploy the app.